How to make something prioritize one event "group" (in the event graph) over another?

Hello, my issue is that I have an enemy that appears to have to events that need prioritizing. The first event is an On See Pawn/Follow Player type event. The Second is an Enemy Patrol type event with up to 4 patrol points for it to travel to. Both events work fine on their own, but when I have both active my enemy gets confused.

It looks something like this: It will follow me if it sees me, but only for the amount of time I have set as the delay time the enemy has from one patrol location to the next. I have experimented with this and have determined to be the same amount of time.

So… my real question is how do I make my enemy prioritize its patrol path UNLESS it sees me, and in which case it will prioritize the Follow Player event as it should (indefinitely)? UNLESS it loses sight of me, in which case it will prioritize its little patrol route.

I will now post screen shots of my event graph, if there is a better way please tell me and I will happily upload it.



Hello. There is a “quick and dirty” way to solve this, and a proper way.

For the easy way forward, you can add a Branch check for “Is Seeing Player” after each delay in your patrol routine, and only proceed if that returns False. You’d also need to add a call to Walking when the pawn sensing concludes so it goes back to the patrol behaviour.

It’s not very scalable however, and you’ll hit some walls if you want to further extend the behaviour of the enemy this way.

A more appropriate way to do this requires some refactoring. First, notice that you have 4 duplicate pieces of nodes in the patrol routine, one for each step. Having duplicate logic usually calls for trouble, since if you want to change how something works you’ll have to perform duplicate work and you could introduce bugs.

You can refactor your patrol logic by using an Array for the MovePoints. That will allow you to have as many MovePoints as you want. You can then have an int variable that begins at 0 and tells you which move point you want to move to. After the delay, you increase the value of this int and perform the same routine again.
Here is a good tutorial on arrays to get started: https://www.youtube.com/watch?v=QHxoIR_3YIY

If you refactor this to using Arrays, you’ll stop having duplicate nodes for the patrol behaviour and will make it much simpler to keep iterating the enemy behaviour.

Thank you so much, I am still learning so I will try both ways you suggested. I appreciate all the advice. I will update when I have time to get on.

1 Like