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.
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.
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
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)
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?