Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    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

Rotation of Charackter, relative to the World

Discussion in 'Animation' started by maltedextrin, Jan 11, 2021.

  1. maltedextrin


    Dec 21, 2020
    Hi Folks!
    I want to set up my Animator Parameter for turning, but i can't get it right.

    if i rotate my charackter counterclockwise (topdown view, with gamepad),
    i want my Animation for turning left be played.
    This is what i got so far:

    if (Turning <0.1) animator.SetFloat("Turn", -1);
    else animator.SetFloat("Turn", 0);

    My Problem is now, that i need to fill my "Turning" variable.

    I wondered if i could just observe the Angle between my Charackter and the world.

    if it grows -> "turn" gets to 1 and vise versa.

    is this possible?

    Im new in coding obviously. I Hope it's not the dumb-question of the day.