So I’m working on a survival horror game and I’m trying to figure out how to make an AI character sprint to me the further away I am. The AI walks by default but I would like for her to accelerate her speed when I’m at a distance.
Posting pictures of what you already have will help a lot, but to get started on this:
You’ll want to manipulate the Character Movement component of the AI character, and specifically the “Max Walk Speed” variable.
You can do some fairly basic math to get the distance between the player and the AI on every update (either Tick, Timer By Event, or whatever other method you want to use for checking this every once in a while).
Divide this distance (which will probably range everywhere from ~25 to a few thousand, depending on what you have distracting the AI to pull them away from your main char) by a certain amount - hazarding a rough guess I’d start around 500 - to get a distance multiplier for the Max Walk Speed.
You can clamp this at any point - either when determining the distance itself, the multiplier, or when setting the actual Walk Speed - to put a cap on it so you don’t turn your AI into the Flash.
Then feed this new speed float over into Persona to update any locomotion animations.
I’m sure there’s more to it than that, but that’s sort of an overview of the approach I would take.
Thanks!! I actually figured it out! Thank you so much!