Download

Yaw and Pitch Replication

Hi,
I am trying to get the yaw and pitch value from the get aim offset function so I looked at the engine source code and they only replicated the pitch value, so I recreated the function in my character class and replicated the yaw, but still not replicated on the dedicated server.

Thanks,



//return Yaw and Pitch values
FRotator ACHCharacter::GetAimOffsets() const
{
	const FVector AimDirWS = CHGetBaseAimRotation().Vector();
	const FVector AimDirLS = ActorToWorld().InverseTransformVectorNoScale(AimDirWS);
	const FRotator AimRotLS = AimDirLS.Rotation();

	return AimRotLS;
}

void ACHCharacter::SetCHRemoteViewPitch(float NewRemoteViewPitch)
{
	// Compress pitch to 1 byte
	NewRemoteViewPitch = FRotator::ClampAxis(NewRemoteViewPitch);
	CHRemoteViewPitch = (uint8)(NewRemoteViewPitch * 255.f / 360.f);
}

void ACHCharacter::SetCHRemoteViewYaw(float NewRemoteViewYaw)
{
	// Compress Yaw to 1 byte
	NewRemoteViewYaw = FRotator::ClampAxis(NewRemoteViewYaw);
	CHRemoteViewYaw = (uint8)(NewRemoteViewYaw * 255.f / 360.f);
}


FRotator ACHCharacter::CHGetBaseAimRotation() const
{
	// If we have a controller, by default we aim at the player's 'eyes' direction
	// that is by default Controller.Rotation for AI, and camera (crosshair) rotation for human players.
	FVector POVLoc;
	FRotator POVRot;
	if (Controller != NULL && !InFreeCam())
	{
		Controller->GetPlayerViewPoint(POVLoc, POVRot);
		return POVRot;
	}

	// If we have no controller, we simply use our rotation
	POVRot = GetActorRotation();

	// If our Pitch is 0, then use CHRemoteViewPitch
	if (POVRot.Pitch == 0.f)
	{
		POVRot.Pitch = CHRemoteViewPitch;
		POVRot.Pitch = POVRot.Pitch * 360.f / 255.f;
	}

	// If our Yaw is 0, then use CHRemoteViewYaw
	if (POVRot.Yaw == 0.f)
	{
		POVRot.Yaw = CHRemoteViewYaw;
		POVRot.Yaw = POVRot.Yaw * 360.f / 255.f;
	}

	return POVRot;
}



Hi Cobra,
I noticed that the SetRemoteViewPitch of the APawn class is not virtual so it cannot be properly overridden. You opted to name your functions SetCHRemoteViewPitch/Yaw. I would make sure that these are being called from somewhere, probably your Tick function should call these and make sure they are getting set.

well why isnt it virtual…