Unity Community


Results 1 to 14 of 14

  1. Posts
    400

    First Person Controller

    where can i found First Person Controller ?

    and in my unity iphone why i dont have 'Standard Assets'' or ''Pro Standard Assets'' ?


  2. Location
    Massachusetts
    Posts
    285
    Look in /Applications/Unity/Standard Packages/Standard Assets.unitypackage
    or where you saved it.

    It wont have any iphone control support yet, but that should not be too hard to implement.


  3. Posts
    400
    /Applications/Unity/Standard Packages/Standard Assets.unitypackage


    this is not for iphone ... it s for unity indie ...or function in iphone ?


  4. Location
    Massachusetts
    Posts
    285
    Im starting to go through and convert the FPS scripts for the iphone....
    here is mouse look...
    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [AddComponentMenu("iPhone/Camera-Control/Mouse Look")]
    5. public class MouseLook : MonoBehaviour {
    6.  
    7.     public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
    8.     public RotationAxes axes = RotationAxes.MouseXAndY;
    9.     public float sensitivityX = 15F;
    10.     public float sensitivityY = 15F;
    11.  
    12.     public float minimumX = -360F;
    13.     public float maximumX = 360F;
    14.  
    15.     public float minimumY = -60F;
    16.     public float maximumY = 60F;
    17.  
    18.     float rotationX = 0F;
    19.     float rotationY = 0F;
    20.    
    21.     Quaternion originalRotation;
    22.  
    23.     void Update ()
    24.     {
    25.         if (axes == RotationAxes.MouseXAndY)
    26.         {
    27.             // Read the mouse input axis
    28.             rotationX += iPhoneInput.acceleration.x * sensitivityX;
    29.             rotationY += iPhoneInput.acceleration.y * sensitivityY;
    30.  
    31.             rotationX = ClampAngle (rotationX, minimumX, maximumX);
    32.             rotationY = ClampAngle (rotationY, minimumY, maximumY);
    33.            
    34.             Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
    35.             Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);
    36.            
    37.             transform.localRotation = originalRotation * xQuaternion * yQuaternion;
    38.         }
    39.         else if (axes == RotationAxes.MouseX)
    40.         {
    41.             rotationX += iPhoneInput.acceleration.x * sensitivityX;
    42.             rotationX = ClampAngle (rotationX, minimumX, maximumX);
    43.  
    44.             Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
    45.             transform.localRotation = originalRotation * xQuaternion;
    46.         }
    47.         else
    48.         {
    49.             rotationY += iPhoneInput.acceleration.y * sensitivityY;
    50.             rotationY = ClampAngle (rotationY, minimumY, maximumY);
    51.  
    52.             Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);
    53.             transform.localRotation = originalRotation * yQuaternion;
    54.         }
    55.     }
    56.    
    57.     void Start ()
    58.     {
    59.         // Make the rigid body not change rotation
    60.         if (rigidbody)
    61.             rigidbody.freezeRotation = true;
    62.         originalRotation = transform.localRotation;
    63.     }
    64.    
    65.     public static float ClampAngle (float angle, float min, float max)
    66.     {
    67.         if (angle < -360F)
    68.             angle += 360F;
    69.         if (angle > 360F)
    70.             angle -= 360F;
    71.         return Mathf.Clamp (angle, min, max);
    72.     }
    73. }

    Its a c# script


  5. Posts
    400
    ok now i see



    tks


  6. Location
    Massachusetts
    Posts
    285
    and here is the FPS walker

    Code:  
    1. var speed = 6.0;
    2. var jumpSpeed = 8.0;
    3. var gravity = 20.0;
    4.  
    5.  
    6. private var moveDirection = Vector3.zero;
    7. private var grounded : boolean = false;
    8.  
    9. function FixedUpdate() {
    10.     if (grounded) {
    11.         // We are grounded, so recalculate movedirection directly from axes
    12.         moveDirection = new Vector3 (iPhoneInput.acceleration.y, 0,iPhoneInput.acceleration.x);
    13.         moveDirection *= speed;
    14.        
    15.         if (Input.GetButton ("Jump")) {
    16.             moveDirection.y = jumpSpeed;
    17.         }
    18.     }
    19.  
    20.     // Apply gravity
    21.    
    22.     // Move the controller
    23.     grounded = (flags & CollisionFlags.CollidedBelow) != 0;
    24. }
    25.  
    26. @script RequireComponent(CharacterController)
    you may want to tweak it as having both scripts mapped to the accelerometer will mess it up.


  7. Posts
    400
    you're a big ... I'm trying to put them into practice these codes.

    thanks thanks thanks thanks


  8. Location
    Massachusetts
    Posts
    285
    It was really simple.. all i did was replace the previous input with
    Code:  
    1. iPhoneInput.acceleration.x or y

    No problem.. glad to help


  9. Posts
    400
    interesting!

    but this script only be replaced at the original?


  10. Posts
    400
    the scripts dont function...


    i replace the originl with your but dont functions


    any idea ?


  11. Location
    Earth
    Posts
    859
    What's happening? There is no way anyone can solve your problem with just 'dont functions'. Try being more specific, like saying what error you are getting or what is happening.


  12. Posts
    400
    ok sorry

    in this code the first person move left and right ... i wont to rotate it .


    Code:  
    1. var speed = 6.0;
    2. var jumpSpeed = 8.0;
    3. var gravity = 20.0;
    4.  
    5.  
    6. private var moveDirection = Vector3.zero;
    7. private var grounded : boolean = false;
    8.  
    9. function FixedUpdate() {
    10.    if (grounded) {
    11.       // We are grounded, so recalculate movedirection directly from axes
    12.       moveDirection = new Vector3 (iPhoneInput.acceleration.y, 0,iPhoneInput.acceleration.x);
    13.       moveDirection *= speed;
    14.        
    15.       if (Input.GetButton ("Jump")) {
    16.          moveDirection.y = jumpSpeed;
    17.       }
    18.    }
    19.  
    20.    // Apply gravity
    21.    
    22.    // Move the controller
    23.    grounded = (flags & CollisionFlags.CollidedBelow) != 0;
    24. }
    25.  
    26. @script RequireComponent(CharacterController)


  13. Posts
    122
    Scinfu are you making sure to attach the scripts to the camera, and player objects?


  14. Posts
    400
    ok now function all ...


    thanks thanks thanks




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •