Difficulty integrating two events within one graph

Hi,

I’m really struggling trying to get my head around how to work with multiple events inside a single event graph.

I am trying to implement functionality such that when the player can see an enemy they don’t move, but when the player can’t see them they move towards the player.

I have managed to get this set up so far, that my player blueprint fires a custom “ISeeYou” event, which each enemy blueprint binds to. That is all working great and each enemy is correctly firing the event when the player sees them. However, as I have implemented my custom event using PawnSensing on the player, an event is only triggered when the player sees the enemies, but NOT when the enemies are no longer visible.

I have created a variable “IsSeenByPlayer” (within the enemy blueprint) that is set to true when the custom “ISeeYou” event is fired, and there is a conditional in between the Tick event and move towards player logic that only allows execution when IsSeenByPlayer is false.

My problem is I cannot for the life of me think of anyway to reset this “IsSeenByPlayer” variable back to false when the “ISeeYou” event is no longer firing. Obviously resetting it back to false after every Tick event is no good as it would overwrite any value already set from the ISeeYou event.

Some kind of timeout is my only valid option so far but I really hate the sound of that and the potential race conditions that could ensue.

Hopefully someone out there can help me!

Thanks

Why you dont you make other event on lost visible contact?

That’s what I’d do ideally, but I’m relying on PawnSensing which only has a “OnSeePawn” event, and there’s no equivalent “OnNotSeePawn” event as far as I can tell.

Might be easier to help if we could see your blueprint layout.

Yeah, that would probably help :slight_smile: Here’s what I have so far…

Enemy BluePrint

Player BluePrint

9128-player+bp.png

I currently can’t think of anyway to reset the “Is Seen” variable back to false, short of using some kind of timer, which I’m really not keen on.

Sorry, I’m pretty new here, would any other info be useful?

Thanks for this Omni, sounds like a great and very thorough solution! I definitely have some serious reading up to do to understand everything (I only started with UE4 today!) and I will get on implementing tonight.

Thanks!

I thought I’d attach the implemented solution in case anyone needs in future. The logic is all still currently on the Enemy blueprint, but like Omni suggested this can quite easily be moved onto the Character BP. Many more things need doing, like ray casting from the eyes rather than centre point, etc. but it’s a decent start.