Play an animation after entering a set distance won't work.

So I want to have my model perform an animation after a set distance, and then play a different animation once you get even closer.

This code isnt working. It will run the 2nd if statement (Walking animation) , but won’t run the 1st one (Attacking animation).And don’t worry about the variables, there set properly.

if (Distance < Attack)

{

animation.Play("Attacking");

}

if (Distance < Encounter){
animation.Play("Walking");

}

If(Distance<Encounter && Distance>Attack)

In the second if, since if the distance is less then attack, is also less then encounter, hence it will always trigger second if, do a test and put second if above the first, it will work too :slight_smile: