Hello, I have a player object which I want to change it’s animation to Up if it’s target is above it Right if it’s target is beside it, and down if it’s target is below it. My player moves towards an object which follows the mouse. Here’s the code I tried where 1 is up 0 is right/let and -1 is down.
if ((mouseAim.position - transform.position).normalized.x > (mouseAim.position - transform.position).normalized.y)
{
animator.SetInteger("Walk", 0);
}
else
{
if (mouseAim.position.y > transform.position.y)
{
animator.SetInteger("Walk", 1);
}
else
{
animator.SetInteger("Walk", -1);
}
}