I have an AI that moves randomly but I'm having trouble setting 4-direction movement animations( left, right, up, and down). I was trying to use the "is within angle" but maybe I'm not doing it right. For example I have.
Ai> within: 0.5 of: 62 > Ai > set animation "move_right"
What behavior are you using to move the AI?
I'm currently using pathfinding
You need to disable "Rotate object" in the behavior settings. And add this event:
On every tick
System For Each AI
System AI.Pathfinding.MovingAngle is within 45 degrees of 0 : AI set animation "Right"
System AI.Pathfinding.MovingAngle is within 45 degrees of 90 : AI set animation "Down"
System AI.Pathfinding.MovingAngle is within 45 degrees of 180 : AI set animation "Left"
System AI.Pathfinding.MovingAngle is within 45 degrees of 270 : AI set animation "Up"
Develop games in your browser. Powerful, performant & highly capable.
Yes my rotate object is unchecked already, but I will try this method and see if it works.
Ok hopefully this is what you mean because I couldn't find
"System AI.Pathfinding.MovingAngle" the closest I could find was "is within angle".
So I have-
System> Every Tick
System> For each (Ai)
Ai>is within angle: 45 degrees to 0
Ai>is within angle: 45 degrees to 90
Ai>is within angle: 45 degrees to 180
Ai>is within angle: 45 degrees to 270
Although the angles look right to me, I might not have it all the way down because the ai will only animate the walk right animation (45 degrees to 0).
No, you need System object, "Is within angle" condition.
And if you have multiple AI sprites, these conditions should be nested inside the "System For Each AI" loop.
OMG, I understand
Thank you soooooo much it works!!