Trigger function only on overlapping player

Hi,

I’ve been stuck trying to display a widget for a player once they overlap with another actor. Unfortunatly, the widget gets displayed on all characters…

This is the blueprint for the overlapping actor:

And this is the widget function, inside the default pawn class/character BP:

Now I’d expect this would only call the function in the character BP that corresponds with the “other actor” since I’m casting to the Life_Pawn BP with the other actor as the object. Unfortunatly, the widget is called on all players…

I also tried a different route, by having the server set a replicated bool:

50452-event_tick.jpg

Again, I’d expect the server to set the bool on his side, and the bool gets replicated to the corresponding client. But now the bool seems to be replicated to all character BP’s since still all players see the widget.

I’m at my wits end, didn’t think it would be this hard to find out how to trigger something only for the overlapping player.

I personally think somethings wrong with the way I use the cast To Life_Pawn node?

Any help appreciated (I’m on 8.1 source btw)

Managed to fix it by comparing the overlapping actor with the player pawn:

Still not sure why that cast went to all the players, but it’s working now so that’s something :d

2 Likes

The easier way to do this is actually just to take the other actor, cast it to your character pawn and then plug that into whatever you want to do. This method you’ve come up with is unnecessarily complex.

You could also cast to any blueprint object you like if you wanted the event to only be triggered by a specific item like a key for example. Casting to a blueprint from the other actor is simply telling the engine to make sure that the triggering actor IS the object you’re casting to. You could even run a PrintString node from the Cast Failed pin and type a message like “You need to find the key” to let the player know what they’re looking for.

There’s an easier way to do this… see my answer below.

Don’t listen to TorQueMoD as you sir, are a genius for figuring this out!!! He has obviously not tried this out in a multiplayer situation as the overlap would trigger the following code for all clients and server. Before I found this I tried running it into a separate custom even only fired on client which didn’t work. Then I tried doing switch has authority which made it work for server but not client and finally I came here and found your check controller to pawn!!

Thank you for this!