- Home /
How can I detect the movement of an NPC?
Hi all :D I'm currently working on a 2D game where the NPC has similar animations to the character with an idle and running animation. I'm very new to the animation side of Unity, and I'm wondering if there's a method or variable that can spit out the x movement of the NPC when put through an animation that changes the position of the character. Unlike the player where I can just grab the horizontal axis input, I do not know how to track this for an NPC, let alone one in animation. If there's a better way to animate NPCs while implementing the idle and running states, that would be even more welcome. This is probably a simple question, so I am sorry for having to ask it because of my obliviousness. Thank you
Answer by KarMa_PlaYzz · Jul 08, 2021 at 09:39 AM
2D Animation in Unity (Tutorial)
This video is a great example. As you can see he uses float parameters for the animator, this way you could determine if an object is moving or not.
Hopefully this helped.
Woah! How did I forget about Brackeys' tutorials :( Thank you for the help, kind Shiba
Your answer
![](https://koobas.hobune.stream/wayback/20220613040011im_/https://answers.unity.com/themes/thub/images/avi.jpg)