Search Unity

FPS Lean function makes player snap forward

Discussion in 'Scripting' started by dragonice501, Sep 28, 2016.

  1. dragonice501

    dragonice501

    Joined:
    Dec 2, 2015
    Posts:
    146
    I have a function that makes the player lean either left or right, but this also causes them to snap forward on the world axis. Is there a way to fix this?

    Code (CSharp):
    1. void Lean(float tilt)
    2.     {
    3.         transform.localRotation = Quaternion.Euler (0, transform.localRotation.y, tilt);
    4.     }
     
  2. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    I don't think you need to fill in the Y component.