Cannot get Velocity of AI

I believe you must add movement input on Event Tick. I’m really not sure how to do this in 2D however I found a solution. It’s probably not the best way to do it since it is kind of buggy but it works. Check it out:

In the AI Controller, add this Event

Then, make a boolean variable “SawPlayer” or whatever, and set/unset it on Perception Updated event, like so:

And on Event Tick (again on AI Controller), you should call Update Animation event that we just created, and then check if SawPlayer bool is true, if so, get player location + self location (AI’s location) and then compare their values on the X axis. Accordingly, we can add movement inputs. Afterwards we have to handle the rotation. We can do that by comparing the X axis again, and again accordingly, set the rotation.

Try this out and let me know it is at least close to what you’re trying to achieve. As I said, I’m not the best with 2d however with some tinkering you can improve this a lot. Good luck!

1 Like