We’re designing a first-person multiplayer game, and we want our pawns to look with their heads into the direction they are actually looking. For this, we looked into the ShooterGame example, and noticed that they make use of the replicated property:
APawn::RemoteViewPitch
The problem we have, is that no matter what we do, this value is always zero on all clients.
When a player looks up with the mouse, we call:
APlayerController::AddControllerPitchInput(float Val);
Which updates the rotation of the controller, located at
AController::ControlRotation
This property is not replicated. However, we expect the controller to set the RemoteViewPitch for us.
Now inside APawn, we spotted this:
void APawn::Tick( float DeltaSeconds )
{
Super::Tick(DeltaSeconds);
if (Role == ROLE_Authority && GetController())
{
SetRemoteViewPitch(GetController()->GetControlRotation().Pitch);
}
}
Apparantly the server updates the replicated pitch value. However, for that it uses a struct that is not replicated! And now the weird part is, this pitch apparantly does get updated in ShooterGame. We’ve compared our code with the ShooterGame’s code, and we cannot figure out why it isn’t working for us. We can’t find any hidden booleans we have to toggle on, or any other properties related to this.