Call Custom Event in Character Blueprint after Player Controller has spawned Pawn on the server

Hi All,

Currently I’m spawning players on the server via Player Controller but the issue is that when this happens, Characters Event BeginPlay calls multiple times and I only want it to call once on each client/server. It’s mostly all local inputs so doesn’t need to be broadcasted.

So I setup a custom event in the Character BP not sure how to call it from the Player Controller. I guess I just need a way of the server telling the client that it’s finished spawning and they need to begin their local setup.

I’m new to this so it I’m sure it’s an easy answer but struggling to figure it out

Here’s the Player Controller Spawning events

Hey,

Is there a reason your spawning the characters via the Player Controller and not the default Game Mode Default Player Pawn? If there is then just make sure that you null out the character in the GM to make sure you aren’t spawning multiple. That might stop the issue with it hitting BeginPlay multiple times.

Also if you want to know when its setup fully then you can override the Possess function in your Controller and then cast to the Pawn and call the Events you need there.

Hi thanks for the response,

I guess no real reason, just thought it might be easier to spawn manually when it comes to different character classes in the future, plus I was following a tutorial that did it this way. I tried using the default GM player pawn approach and seems to do the same thing, calls Characters blueprints BeginPlay multiple times. I did also set as None when spawning via blueprints

I tried the On Possess event in the PC which looks like a step forward! However that seems to only call on the server now so the clients local event won’t call, here’s a sample of what I tried to do

So on the Pawn/Character there is a NotifyControllerChanged function you can use here that runs on Server and Owning Client.

Alternatively, you could run a Client RPC in the controller here to tell the Client to run it as well.

Thanks that’s perfect!

1 Like

Nice glad to hear it @Jonsby :smile:

I’m using a custom default pawn setup that calls the controller when the world (Map) has loaded enough. The controller in turn sends an rpc to the servers copy of the controller which calls a function in the game mode to spawn the character.

Seems complicated but it’s really easy. I have custom cosmetics and use modular characters. Same process would be used for character child classes or even completely different character parent classes.


Game Mode Class settings… Note default pawn class

Loading Pawn… Demo version
Production version replaces the delay with a recursive loop (timer event) that checks for specific actors existence in the level.

Code execution only happens on the Autonomous Client. Not on Sims or Server.

Player Controller Class…

Game Mode Class…

GM Srv Spawn Character function…

Another aspect of this function is to set a cosmetic config variable (Struct, RepNotify). The Onrep function assembles the character.