I have a class inheriting from character and a controller. In the controller i want to spawn the character. It has to be replicated on all clients. Which steps, in code, do i need for this? i can’t get it to work for myself… .
I tried many things but i can’t get the pawn to show on other clients. There aren’t a lot of clear explanations about this stuff.
UPDATE:
I’ll show you what i have tried so far.
In the controller’s header i have:
UFUNCTION(Server, Reliable, WithValidation)
void serverSpawnPawn();
void serverSpawnPawn_Implementation();
bool serverSpawnPawn_Validate();
Inside the begin play function of the controller i call this
if (Role == ROLE_Authority)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("server")));
serverSpawnPawn();
}
And for the serverSpawnPawn i have this:
void AFlappyBirdController::serverSpawnPawn_Implementation()
{
FActorSpawnParameters spawnParams;
APlayerCharacter* pawn = GetWorld()->SpawnActor<APlayerCharacter>(pawnTypes[mode], FVector(0, 0, 0), FRotator(0, 0, 0), spawnParams);
Possess(Cast<APawn>(pawn));
owningPawn = pawn;
}
bool AFlappyBirdController::serverSpawnPawn_Validate()
{
return true;
}
Then my pawn is inheriting from ACharacter.
I ticked every checkbox in my controller and pawn that says something about should replicate and things like that so i don’t know why they are not on all clients. It’s only visible on it"s own screen.