Search Unity

Camera freelook jitter when I first move the player

Discussion in 'Cinemachine' started by Pixitales, Jan 11, 2020.

  1. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    180
    Its a 3D platformer game with freelook camera. It follows the Player parent gameobject. Player has rigidbody Interpolate. It always jitters when I first move for a few seconds and then everything feels smooth after that. Same thing with the game controller. Why is that?

    Code (CSharp):
    1.  private void SetVelocity(Vector3 velocity)
    2.     {
    3.         MyRigidbody.velocity = velocity;
    4.     }
    5.  
    6.     private Vector3 CalculateMovementDirection()
    7.     {
    8.         Vector3 velocity = Vector3.zero;
    9.  
    10.         float horizontalInput;
    11.         float verticalInput;
    12.  
    13.         //Get input;
    14.         horizontalInput = Input.GetAxis("Horizontal");
    15.         verticalInput = Input.GetAxis("Vertical");
    16.  
    17.         velocity += transform.right * horizontalInput;
    18.         velocity += transform.forward * verticalInput;
    19.  
    20.         if (velocity.magnitude > 1f)
    21.         {
    22.             velocity.Normalize();
    23.         }
    24.  
    25.         return velocity;
    26.     }
    27.  
    28.     private Vector3 CalculateMovementVelocity()
    29.     {
    30.         Vector3 velocity = CalculateMovementDirection();
    31.  
    32.         velocity *= playerStats.MyMoveSpeed;
    33.  
    34.         return velocity;
    35.     }
     
  2. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    180
    nvm i fixed it
     
unityunity