Hello! I have been trying to learn networking, and got some progress, but now stuck here: I need to run on server an even, that applies momentum to the mesh of a pawn of a client that launched the event. How can I get a reference to the one requesting the function to be run on server
So you have a Custom Event that is “Run on Server” and you need the player that calls it?
Try using the Input that you can define for the Custom Event.
Click on the Red Node and look to the lower left side of the Blueprint where you also
set the “Run on Server”. There you should setup Input like in normal functions.
Here you can add an Input of type PlayerPawn or your PlayerCharacter or what ever.
The Blue node will update. Maybe you need to right click the Blue node and click on something
like “Update Nodes…” or so.
I actually got it working now Here is how I did it (for future reference, as I am sure someone else will at some point be interested in this):
- you need to have “Pawn” in your event as one of the inputs.
- you need to (client side) input “self” into the pawn slot
- in the event, you take the “pawn”, and use it as an object for “Cast to [NAME]”. [NAME] being the name of the pawn class.
- Congratulations! You now have a working reference to who called the event!