Actor Spawned on server, doesnt appear on client

Hey, I know there are a tonne of questions about this, but they all concern blueprints and not how to do it in C++!
I did come across:


These seem like fixes, but after following the solution it still does not seem to work.

So I have a ship that’d id like to spawn at the beginning of the game and be replicated to clients:

In my gamemode constructor I have this:

// I.e We're the server
	if (Role == ROLE_Authority) {
		static ConstructorHelpers::FObjectFinder<UBlueprint> ShipBP(TEXT("Blueprint'/Game/Blueprints/BP_LightCruiser.BP_LightCruiser'"));
		if (ShipBP.Object){
			UE_LOG(LogTemp, Warning, TEXT("Found the ship BP!"));
			// Spawn in a new ship, stick it at 0.0.0
			AShip* NewShip = SpawnBP<AShip>(GetWorld(), (UClass*)ShipBP.Object->GeneratedClass, FVector(0, 0, 10), FRotator(0), true, this, NULL);


AShip::AShip(const FObjectInitializer& PCIP)
: Super(PCIP)
	bReplicates = true;
	//bNetLoadOnClient = true;
	bReplicateMovement = true;
	bStaticMeshReplicateMovement = true;
	//bAlwaysRelevant = true;

	// ??
	//Hull = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ExternalHull"));

void AShip::Tick(float deltatime)


class SPACEGAMEII_API AShip : public AStaticMeshActor
	void Tick(float deltatime) override;

	// Constructors
	AShip(const FObjectInitializer& PCIP);


On starting the game with a listen server and a single client, I can see the ‘ship’ appears server side, but not clientside - anyone got any pointers to help me out?

Thanks :slight_smile:

You shouldn’t be setting it to be a simulated proxy. Delete that line.

Secondly, StaticMeshActors are Static and don’t have movement components. If you want to posses the ship and have it move or have the AI move it, then it needs to be a Pawn or Character.

Hey, thanks for your answer, I might’ve been slightly misleading when I named it a ship, it is not intended to be possessed by the player, or even ai controlled (at least for now).

if I’m understanding correctly - your saying that I can’t replicate static mesh components at all? ( I suppose this makes some sense , seeing as that object would never need to be updated after spawning ), and should i want a replicated mesh, I should use a different component - say a uprimitive component instead?

Thanks for reading!

PS, sorry for the flurry of questions

Derive your AShip from AActor and add a UStaticMeshComponent to it. StaticMeshActors are meant to be placed in a level and be…static.

Alright, after following your advice,
in addition to the previous errors you mentioned,

Ive managed to get it working by taking the spawn command out of the constructor and placing it into BeginPlay() (Not sure why this causes a problem, but there we go )


Thanks again for your time, I really appreciate it!

The other thing I noticed is that you were checking in the gamemode if it was Role == ROLE_Authority and the gamemode never runs on the client only on standalone, listen, and dedicated servers.