How do I get my AI to continue wandering/roaming?

Hello. I am trying to figure out how to get my AI character to continue roaming after they have “reached” me. Currently, when the AI character reaches me, it stops roaming and only moves when I go into it’s line of sight. I’d like it to immediately continue to roam after touching me, then when I move into it’s LOS, chase me, stop when it reaches me, etc.

Current Blueprint setup: http://gyazo.com/bd576af75b34892c0bbeb3e9f8dad8db

To narrow it down, currently the AI does this:

  1. Roams around.
  2. Sees me.
  3. Chases me.
  4. Touches me
  5. Stops and only moves when I’m in it’s LOS. (I’d like it to continue roaming once it reaches me, assuming it can’t see me, because if it sees me then I’d like it to chase me, which is already does.) Hope this makes sense.

Thanks for any assistance. :slight_smile:

Weeeeell, first I would suggest you use [AI Behaviour Trees][1]. But that’s not really the solution to your problem, just a general recommendation.

Your problem is, that immediately after the move to was successful, it is triggered again. The “In range” does not seem to be set to false again (ever). But even when you would, it would be set to true immediately again, because the AI is still standing right next to you.

I guess what you want is some kind of cooldown. Maybe introduce a variable “last touched” which you set to the current upon touching you. You could then check this variable and make sure that the AI does not start chasing you again before some has passed

https://docs.unrealengine.com/latest/INT/Gameplay/AI/index.html
[2]: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseTimers/Blueprints/index.html

Hi,

You can set how often the AI checks the sensing.

I have mine set to

50548-capture.jpg

when I go behind a wall with enough distance, the AI gives up.

Not the best example as mine does not move, but you might be able to see that when I move behind the glass, he stops firing as he can not longer see me. (Ignore the irony)

This is an overview on how I dealt with sensing.

I’m slightly confused. Will doing what you said make it so the AI chases me after it reaches me, instead of standing there and only moving again when I run in it’s LOS?