Projectile replication/relevancy in multiplayer

Hi,

I’ve been fighting with this issue over the weekend and still no solution.
The problem I am having is that:

  • PIE 2 players
  • Server (Listen) + Client
  • Server fires projectile - Works
  • Client player shoots projectile while in the Server’s player viewport - Works
  • Client player shoots projectile out of the Server’s player viewport - Broken

Problem is, when a client is within the Server’s player viewport and fires his projectile, both himself and the player on the server, see the projectile correctly.
When client player moves far away from the player local to the server, and shoots his weapon, he either does not see the projectile at all, or sees the projectile being fired in a completely different direction.

Weapon actor has a Server RPC which creates the projectile


FTransform SpawnTM(GetMesh()->GetSocketRotation(MuzzlePoint), GetMesh()->GetSocketLocation(MuzzlePoint));
AProjectile* Projectile = Cast<AProjectile>(UGameplayStatics::BeginSpawningActorFromClass(this, ProjectileClass, SpawnTM));
if (Projectile)
{
	Projectile->Instigator = Instigator;

	AActor* CurOwner = Instigator->GetController();
	Projectile->SetOwner(CurOwner);

	UGameplayStatics::FinishSpawningActor(Projectile, SpawnTM);
}

As you can see, I’m setting the projectile’s owner as the shooter’s controller (the controller of the current weapon instigator) and in the Projectile’s constructor I’m setting:


bReplicates = true;
bReplicateMovement = true;
bNetUseOwnerRelevancy = true;

bAlwaysRelevant doesn’t make any difference.
Any idea what is going on here?

Seems my assumption was wrong, and led me to waste quite some time.
The problem lies on the Weapon actor not the Projectile.

The problematic code is:


FTransform SpawnTM(GetMesh()->GetSocketRotation(MuzzlePoint), GetMesh()->GetSocketLocation(MuzzlePoint));

This returns bad values when not in the server’s viewport.
This works:


FTransform SpawnTM(Owner->GetActorLocation(), Owner->GetAimRotation());

Now I wonder why the server has bad weapon location/rotation.
Is it because the weapon is attached to a socket in the character’s mesh?

Weapon is obviously Replicated, and movement too.

Solved, problem now was that when I was setting owner of the weapon using SetOwner, I was passing the wrong actor.
Thanks.