Projectile replicates at wrong location

Hi,

I’ve created a player and projectile classes using First Person Shooter C++ Tutorial. I’ve also created an RPC function to handle projectile spawning on the server. The projectile and its movement is replicated.

The problem is that the client projectile is “shifted”. It spawns at the side of the player instead of the center. The other thing is that when I shoot the other player the projectile bounces off about 1-2 meters before that player. Everything works fine on the server though (projectiles are spawned in the center and the collisions work fine).

The spawning function:

void AFPSCharacter::ServerOnFire_Implementation(FRotator Rotation)
{

	if (ProjectileClass != NULL)
	{
		FVector const MuzzleLocation = GetActorLocation() + FRotationMatrix(Rotation).TransformVector(MuzzleOffset);
		FRotator MuzzleRotation = Rotation;
		MuzzleRotation.Pitch += 10.0f;
		UWorld* const World = GetWorld();
		if (World)
		{
			FActorSpawnParameters SpawnParams;
			SpawnParams.Owner = this;
			SpawnParams.Instigator = Instigator;
			AFPSProjectile* const Projectile = World->SpawnActor(ProjectileClass, MuzzleLocation, MuzzleRotation, SpawnParams);
			if (!Projectile)
				return;

			FVector const LaunchDir = MuzzleRotation.Vector();
			Projectile->InitVelocity(LaunchDir);
		}
	}
}

Does anyone know why is this happening?

Try adjusting muzzleoffset in your instance.

It’s possible the projectile is colliding with the character collision component instead of the mesh.

The muzzleoffset is fine. Projectiles spawned in the server work just fine, the problem is with the client only.

I have this same exact problem. Were you able to find a solution?