Begin Play not called on client

Hello !

I have a little problem which may be easy to resolve :
my BeginPlay function in my character is called only on server side …

case :
my player controller server side spawn a character, and possess it.
I use Development Server and Development Client to test and play.

Code to spawn my character :

	FActorSpawnParameters parametres;
	parametres.Owner = this;
	AC_Personnage *perso = ()->SpawnActor<AC_Personnage>(AC_Personnage::StaticClass(), FVector(-160, 0, 150), FRotator(0, 0, 0), parametres);

	if (perso)

the character and his begin play function :

  class NOUVEAUJEU_API AC_Personnage : public ACharacter

	virtual void BeginPlay() override;

and the start of beginplay

void AC_Personnage::BeginPlay()

I know that it’s called only on server because neither the server nor the client crash, the client part should remove widgets and the server part launch a timer. Widgets aren’t removed while the function called by the timer runs fine.

I event tried to put an UE_LOG just before the Call parent but only the server print the warning … If you know where is the problem I will be really happy !!!

Have a nice day !!!

Player Controller don’t exist in client side for security reasons. There PlayerState class that is dedicated for public information about player avable to anyone (there also GameMode which is also not replicated equivalent GameState) and HUD can grab information from there, i recommend ot use UMG binding (Slate has it to if you use that)

You can also use function call replication so playercontroller can send something to character or other object, there section dedicated about it here:

You can also try to hook up to other event. Remember about security, even if you don’t provide any UI to specific function, even if you don’t display information that you replicate, you need to remember that user has free access to memory of there machine and free access to there network IO and they can do anything to them with external software. So you need to strictly control what is replicated and what is not and what client and server should listen to.

Thanks for your answer but I may not understand : the “BeginPlay” of a character (pawn derived) is called only on server ?

(don’t worry I know for the hack tools, everything important is controlled and calculated server side)

Ah sorry :o i thought mean PlayerController, i rushed thry your quastion too much ^^’ hmm i still posted good workaround thru. I also analized actor code a bit and by look of it BeginPlay should work, it seems for replicated actors it is triggered inside PostNetInit event, you use it and not calling super there it might be the cause of BeginPlay not calling.

You could also try using PostNetInit if you not using it see if it’s called at all. Put your code after super so actor will be in post beginplay state to make sure everything is initiated.

don’t worry >< I was just afraid that the replicated function can be called before the actor is created on the client (because of network latency or delayed packets …)

I will try your workaroud for now !

There definitely way to hook up, it’s not like you see some magical ghosts projections from server, there is code executed on client to do all the visual stuff, if the BeginPlay don’t work (which if you ask me i didn’t know about this, i didn’t work with replication, i only as brief knowledge about it) try to hock up to different events, try PostInitComponents event for example, just remeber that this is also called in editor when you place it on the level). Look on AActor API refrence, you can hook up the code on any virtual function so chekc what works on client and place code there:

Thank you !! PostInitializeComponents() will replace (for now) the BeginPlay.

Ok totally my bad … some constructors were badly declared (in playerState and GameMode) …