Download

How do I run a server side character class specific check?

I’m trying to run a check if any player on the server is using a specific character blueprint “ControllerChar”, my goal is to make it so only one player can use the character blueprint at any given time. Thanks in advance!

bphelp.jpg

I have made an assumption from your question that you are doing a multi-player game, if not you then have to pass a player index to the “Get Player Character” call.

Don’t use “Get Player Character” … that does not work for Multiplayer.

If you are on the Character Blueprint - use “Get Controller”
If you are on the Player Controller Blueprint - use a reference to self.
If you are on the HUD Blueprint - use “Get Owning Player Controller”.
If you are on a HUD Widget Blueprint - use “Get Owning Player” and then “Get Controlled Pawn”.

These can all then be cast to the controller in question and you can do your validity check there. These are what I am using and my game runs perfectly in multi-player including with a dedicated server and a listen server. I have not used one call to “Get Player Character” anywhere in my code … this is an important thing to keep in mind if you are building multi-player from the start.