Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Own player controller script let the view wobbles but why?

Discussion in 'Scripting' started by sgrgame, Jul 27, 2019.

  1. sgrgame

    sgrgame

    Joined:
    Feb 12, 2019
    Posts:
    1
    Hello Unity friends,
    I have an problem with my little player control script when i rotate and move the player in one time.
    The nice fail can you see here: https://kacklappen.tinytake.com/tt/MzY2ODcxNF8xMTEyOTcyMg
    and my 'nice' script can you see here:
    Code (CSharp):
    1.      private void Update() // rotate part - actually rotate only on y axis
    2.      {
    3.          vert = Input.GetAxis("Vertical");
    4.          hor = Input.GetAxis("Horizontal");
    5.          yaw += rotSpeed * Input.GetAxis("Mouse X");
    6.          transform.eulerAngles = new Vector3(0, yaw);
    7.      }
    8.      private void FixedUpdate() // move part
    9.      {
    10.          if (vert == 0 && hor == 0)
    11.              return;
    12.          transform.position += ((transform.forward * vert) *moveSpeed + (transform.right * hor) * moveSpeed);
    13.      }
    Thank you for help :)
     
  2. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    242
    Start by reading what Time.deltaTime does. Then you will understand many of your issues.
     
unityunity