Spawn Actor from Client but on Server

Hi All,

I need to be able to let Client player spawn an actor that gets replicated on both Clients and Server.

It is currently working fine if the Server player does the spawn, but I can’t figure out how to let the Client player do it.
I would like to use code really but this simple cube example of several pages put me off so I thought to try Blueprints.

Would anyone be able to tell me how to use ‘Replicates: Run On Server’ on a ‘Custom Event’ node ??
(The Authority bit at the top seems to work, but not the ‘Remote’ part)

Take a look at this page
How to Replicate Functions in Blueprints

Thanks a lot, I hadn’t seen that page!

I have to go through and see how they have set up their characters as my setup isn’t the same. I was trying to spawn in the Level Blueprint while they seem to do it through actors already spawned into the game. Hopefully it will give me some leads though.

Hmm…this is still very mysterious and eludes me. I can replicate what they do in that page in that exact setup (ThirdPerson example).
But my setup is different and I don’t think I am doing anything ‘wrong’ :slight_smile:

There must be a rule or law or something that I am breaking I just don’t know what!?
In the docs they say about RPCs that:

  1. “They must be called from Actors.” CHECK, I am doing this in the bluePrint of a blueprint of a class based off ‘Actor’. (called ‘Console’)

  2. “The Actor must be replicated.” CHECK, I spawn this ‘Console’ on BeginPlay, in the ‘level Blueprint’, on the server which then promptly Replicates to Client.

  3. “If the RPC is being called from client to be executed on the server, the client must own the Actor that the RPC is being called on.”
    I am not doing anything in particular for this. But I am also doing everything just like in the example ThridPerson scene. I have also tried to use ‘Switch Has Authority’ without success.

Does anyone know what step I am missing?

Here is my new BP inside the ‘Console’ blueprint object:

  1. “Owned” means possessed by player.

The owning client is key. I haven’t found how to set owner in BP, there doesn’t seem to be a node for it. In C++ its as easy as doing


If you don’t want to dive into C++ what you can do is move this functionality to a class that is automatically owned by the player, like a player controller BP (for sure) or a pawn BP (not sure if its owned automatically). By the way, have you checked that the InputAction itself is being triggered, using a print? InputActions only reach non-Pawn, non-PC objects if you do SetInputEnabled on the actor.

Edit: Oh thats right it did work on server, so your input must be set up then. Ignore that last bit. :slight_smile:

Thanks so much guys and extra thanks Nisshoku that was very helpful!
My bp objecta actually originate from my own c++ classes/objects so ill go back and try that first.
I tried to do this in bp just because spawning in code seemed a bit of a hassle and i just needed temp functionality.

Will try as soon as i get time, which is probably tomorrow or something but will post back here for anyone else interested.


Been working too much so just got back to this! :slight_smile:

I have tried to get hold of the active player controller so that I can set the owner of my ‘Console’ to it.
I fail.
This is what I’ve got at the moment:

‘Console’ .h :

APlayerController* PC;

then in ‘Console’ .cpp BeginPlay() which works with other code in it :

// getting player controller so we can possess
for (TActorIterator<AActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
	APlayerController* PCtmp = Cast<APlayerController>(*ActorItr);

	if (PCtmp)
		PC = Cast<APlayerController>(*ActorItr);

if (PC) {
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("GOT A PLAYER CONTROLLER!"));

I do get the printout message but that must still not be right as the spawn+replication from the blueprint still does not happen in my client copy of the game.
Can anyone see what I do wrong?

EDIT: Also tried this with no success,

if (PCtmp->IsLocalPlayerController() && Role < ROLE_Authority)

Cheers, F

Have you checked the wiki yet?

hmmm…sounds like what you needed?