Search Unity

Rotation of Charackter, relative to the World

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

  1. maltedextrin

    maltedextrin

    Joined:
    Dec 21, 2020
    Posts:
    1
    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.