I am trying to spawn a unique actor for each player, as far as i can tell the documentation says all you have to do is:
- bReplicated = true
- bOnlyRelevantToOwner = true
- specify owner in FActorSpawnParameters
- Spawn object from the server
However when i do this all the actors just spawn for each player anyway. So i tried to override ‘IsNetRelevantFor(…)’ with “return RealViewer == GetOwner()”, which did not changed anything. Even if i simply return false for ‘IsNetRelevantFor(…)’ the object STILL replicates to all actors eventually. I say eventually because it seems they spawn later on actors that do not own the object.
In MyPlayerController::OnConstruction :
if (HasAuthority())
{
FVector Location(0.0f, 0.0f, 0.0f);
FRotator Rotation(0.0f, 0.0f, 0.0f);
FActorSpawnParameters info;
info.Owner = this;
m_pGameView = m_pWorld->SpawnActor<APlayerGameView>(Location, Rotation, info);
}
In the constructor of the actor supposed to be unique per player and replicated on the server:
APlayerGameView::APlayerGameView()
{
PrimaryActorTick.bCanEverTick = true;
AActor::bReplicates = true;
AActor::bOnlyRelevantToOwner = true;
AActor::bAlwaysRelevant = false;
}
This is really strange behavior to me, how should i spawn a actor with an owner and only replicate it only to that owner the right way?