Hello everyone,
I want to play a walk animation if a unit is pushed aside by local avoidance. Unfortunately I am uncertain on how to check the movement and the direction. The behavior which I desire is something like the unit which is pushed aside turns into the direction of movement and plays it’s walk animation. Currently the unit just slides to the new position.
![Bildschirmfoto 2022-06-20 um 19.49.40](//forum.arongranberg.com/uploads/default/original/2X/a/ade49ecafd08a66d0d4a3b0d1b899cd5b0fe58af.png)
The priority will be changed through a script. When a destination is set the priority will be set to 0.7 and if the destination is reached ist will be reset to 0.1 .
Thank you in Advance.
Hi
How are you currently getting the velocity for the animation? Driving it using ai.velocity
should work I think.
Hi,
currently I am using a bool which is set to true(transition to Walk) the moment a direction is set and reset to false (transition to Idle) when ai.reachedDestination is true.
You are right I totaly forgot that I can check if the ai has any velocity.
I am still new to game development and especially Programming with a focus on performance. Therefore the question rises would if it would be too costly to run the check in the Update Method and trigger the Animation? I plan for several hundred of units at a time something between 100 and 200. If all of them checking for velocity every frame I could imagine that this could hurt the performance/frame rate.
Just checking for the velocity every frame for 100 units is peanuts for a modern computer
Don’t worry about it. The AIPath script itself does way more than this every frame.
Okay thank you.
I just tested it and it is working perfectly.
1 Like