Search Unity

Using an OnLook event causes jitter (sometimes)

Discussion in 'Input System' started by ReeceXW, Apr 28, 2020.

  1. ReeceXW

    ReeceXW

    Joined:
    Oct 8, 2019
    Posts:
    2
    Hey, I'm using Unity 2020.1 but have also tried this in 2019. I have setup input actions and a basic player controller.

    show1.PNG

    It feeds the input events to the PlayerController.
    In the player controller I just have some simple camera control

    Code (CSharp):
    1.  var delta = context.ReadValue<Vector2>();
    2.  
    3. var playerRotation = gameObject.transform.eulerAngles;
    4. var cameraRotation = m_camera.transform.eulerAngles;
    5.  
    6. playerRotation.y += delta.x * Time.deltaTime * 10.0f;
    7. cameraRotation.x -= delta.y * Time.deltaTime * 10.0f;
    8. cameraRotation.y = playerRotation.y;
    9.  
    10. gameObject.transform.eulerAngles = playerRotation;
    11. m_camera.transform.eulerAngles = cameraRotation;
    Now this works(ish). Sometimes this is flawless; completely smooth. Other times when I enter play mode I get this terrible stutter between updates, rotation my camera upwards of 20 degrees between frames. Any reason this would happen with the above logic?

    *EDIT
    I've also put this into the update method and switched to using current mouse. It's slightly less noticeable but I'm still having stutter issues