Getting clients to see other player's aim movements?

I’m having trouble getting clients to see each others movements when aiming. For example, when one player aims up, the others players should see that. Right now, only the player on the listen server can see aiming movements of the other players. I was under the impression that character movements/animations were replicated. But it seems that aim angles do not. Do I need to set up special replicated variables to deal with this or did I miss something?

Never mind. I found the problem. I had a variable for the AimPitch that was not set to replicate properly.

As a quick note - sometimes aim offset animations use control rotation to do this instead. This exists in the controller, but these are only shared between the owning player and the server, i.e. remote clients won’t have a controller connected to the other players’ pawns that they can see in the world.

To get around this, the server should set a replicated FRotator in the character/pawn (since it will receive the control rotation from the owning client automatically), and so all remote clients will receive it. The owning client should also set this variable, so it matches. The variable should be marked to skip the owner when replicating, since they’re where the value came from in the first place! I do this on Tick.

Don’t forget to mark the NetworkedViewRotation FRotator variable as ‘Replicated’ in your header file, and to add it to the replication setup function.


// In AShooterCharacter's class declaration (header file)
UPROPERTY(BlueprintReadOnly, Replicated, Category = "Movement")
FRotator NetworkedViewRotation = FRotator::ZeroRotator;


void AShooterCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	DOREPLIFETIME_CONDITION(AShooterCharacter, NetworkedViewRotation, COND_SkipOwner);

	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
}


// Called every frame
void AShooterCharacter::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	// Pass any movement info to clients.
	UpdateNetworkedViewRotation();
}



void AShooterCharacter::UpdateNetworkedViewRotation()
{
	if (Controller != nullptr) // only local and server will pass
	{
		NetworkedViewRotation = GetViewRotation();
	}
}

You can then get this NetworkedViewRotation variable from a reference to the AShooterCharacter (or one of its blueprint-inheriting subclasses) in your animation blueprint’s event graph, and feed it into a variable used by an aim offset.

I know this isn’t your issue, but it might help someone else! :slight_smile: