Search Unity

animation problem with eulerAngles

Discussion in 'Animation' started by lyokoguerier_unity, Aug 30, 2019.

  1. lyokoguerier_unity

    lyokoguerier_unity

    Joined:
    Feb 14, 2018
    Posts:
    86
    Hello everyone

    I have a problem I'm writing a script for a 3D character under Background 2D May I have a rotation offset problem


    Code (CSharp):
    1. public float Walk = 3 ;
    2.  
    3.  
    4. void Update () {
    5.  
    6.  
    7.         if (Input.GetKey(KeyCode.DownArrow)) {
    8.  
    9.             transform.Translate (0, 0, Walk * Time.deltaTime);
    10.             GetComponent<Transform>().eulerAngles = new Vector3(0, 0, 0);
    11. anim.Play ("ANH_MAIN_F0_FRJ_RUN");
    12.          
    13.  
    14.  
    15.  
    16.         }
    17.  
    18.         if (Input.GetKey(KeyCode.LeftArrow))
    19.         {
    20.             GetComponent<Transform>().eulerAngles = new Vector3(0, -90, 0);
    21.             transform.Translate(0, 0, -Walk * Time.deltaTime);
    22. anim.Play ("ANH_MAIN_F0_FRJ_RUN");
    23.  
    24.  
    25.  
    26.         }
    27.  
    28.         if (Input.GetKey(KeyCode.RightArrow)) {
    29.  
    30.             GetComponent<Transform>().eulerAngles = new Vector3(0, 90, 0);
    31.             transform.Translate (0, 0, -Walk * Time.deltaTime);
    32. anim.Play ("ANH_MAIN_F0_FRJ_RUN");
    33.        
    34.  
    35.  
    36.         }
    37.  
    38.  
    39.         if (Input.GetKey(KeyCode.UpArrow)) {
    40.  
    41.             transform.Translate (0, 0, Walk * Time.deltaTime);
    42.             GetComponent<Transform>().eulerAngles = new Vector3(0, 180, 0);
    43. anim.Play ("ANH_MAIN_F0_FRJ_RUN");
    44.      
    45.  
    46.         }
    47.        
    48.     }
    I have this problem only in the left right keys

    I heard that my animations that makes me this rotation problem

    is what has a solution to this problem ?