Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

FPS1.3 Basic Walking/Running.

Discussion in 'Editor & General Support' started by PrimitiveCreations, Apr 16, 2015.

  1. PrimitiveCreations

    PrimitiveCreations

    Joined:
    Apr 15, 2015
    Posts:
    10
    I don't really know the best way to articulate my question. I was doing ETeeskiTutorials on Basic Wallking/Running, and when I enter in the same code he did and hit play, my capsule goes up into the air ever so slightly and then as soon as I move my mouse it launces into infinite space upward never to be seen again... I don't understand why this is happening.

    For more insight:
    http://postimg.org/image/cpxjqxy2h/
    http://postimg.org/image/ydmi1dygp/

    What happens when I hit play notice capsule jumps up slightyly:
    http://postimg.org/image/z4jtkwq7t/

    And as soon as I move mouse notice how small the plane has become due to the fact that I am going up infinetly;
    http://postimg.org/image/rd33mcm2h/

    This is the PlayerMovementScript

    Code (JavaScript):
    1. var walkAcceleration : float = 5;
    2. var cameraObject : GameObject;
    3.  
    4. function Update ()
    5. {
    6.     transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(MouseLookScript).currentYRotation, 0);
    7. }
    And this is the MouseLookScript

    Code (JavaScript):
    1. var lookSensitivity : float = 5;
    2. @HideInInspector
    3. var yRotation : float;
    4. @HideInInspector
    5. var xRotation : float;
    6. @HideInInspector
    7. var currentXRotation : float;
    8. @HideInInspector
    9. var currentYRotation : float;
    10. @HideInInspector
    11. var yRotationV : float;
    12. @HideInInspector
    13. var xRotationV : float;
    14. var lookSmoothDamp : float = 0.1;
    15. function Update ()
    16. {
    17.     yRotation += Input.GetAxis("Mouse X") * lookSensitivity;
    18.     xRotation -= Input.GetAxis("Mouse Y") * lookSensitivity;
    19.  
    20.     xRotation = Mathf.Clamp(xRotation, -90, 90);
    21.  
    22.  
    23.     currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, xRotationV, lookSmoothDamp);
    24.     currentYRotation = Mathf.SmoothDamp(currentYRotation, yRotation, yRotationV, lookSmoothDamp);
    25.  
    26.     transform.rotation = Quaternion.Euler(currentXRotation, currentYRotation, 0);
    27. }