Trigger function only on overlapping player
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:
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)
asked Jul 16 '15 at 03:13 PM in Blueprint Scripting
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
answered Jul 16 '15 at 06:34 PM
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here