Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

character current angle

Discussion in 'Scripting' started by mvii3iv, Jul 20, 2014.

  1. mvii3iv

    mvii3iv

    Joined:
    Jul 20, 2014
    Posts:
    16
    hello!
    I want to store in to a variable the current angle of my player, I want to know if the player is rotating 90 degrees or every change in its angle.

    I was trying this code :

    float angle = transform.localRotation.z;

    but it is not working, what do you suggest? thank you
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,683
    I would suggest two things,
    One, look at localEulerAngles over localRotation
    Two, look at Angle()
     
  3. mvii3iv

    mvii3iv

    Joined:
    Jul 20, 2014
    Posts:
    16
    Thank you very much!!! you are right.
    this is the code:
    float currentAngle = transform.localEulerAngles.z;

    just in case someone have the same problem.