I have a problem with ue4 networking, i want to spawn an actor only on role authority and i assign owner in SpawnParameters but the owner is different on every client machine.
The code of spawn weapon actor:
void ABCharacter::BeginPlay()
{
Super::BeginPlay();
if (Role == ROLE_Authority)
{
if (WeaponClass)
{
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
CurrentWeapon = GetWorld()->SpawnActor<ABWeapon>(WeaponClass, FVector::ZeroVector, FRotator::ZeroRotator, SpawnParams);
if (CurrentWeapon)
{
CurrentWeapon->SetOwner(this);
}
}
}
}