I currently working on overriding the GetBaseAimRotation function
And I have some problems with coding.
What I want to do, is add a property :
UPROPERTY(replicated)
uint8 RemoteViewYaw;
I need it to work excatly like RemoteViewPitch in Pawn.h
So I override the GetBaseAimRotation
First I write like this:
FRotator MyCharacter::GetBaseAimRotation()const
{
FVector POVLoc;
FRotator POVRot;
POVRot = ACharacter::GetBaseAimRotation();
if (Controller != nullptr && !InFreeCam())
{
return POVRot;
}
// If our Pitch is 0, then use a replicated view pitch
if (FMath::IsNearlyZero(POVRot.Yaw))
{
// Else use the RemoteViewPitch
POVRot.Yaw = RemoteViewYaw;
POVRot.Yaw = POVRot.Yaw * 360.0f / 255.0f;
}
return POVRot;
}
I think a ACharacter:: or Super:: statement should let me call the parent version explictly
But it didn’t.
So I expand the statement:
FRotator MyCharacter::GetBaseAimRotation()const
{
FVector POVLoc;
FRotator POVRot;
if (Controller != nullptr && !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 a replicated view pitch
if (FMath::IsNearlyZero(POVRot.Pitch) || FMath::IsNearlyZero(POVRot.Yaw))
{
if (BlendedReplayViewPitch != 0.0f)
{
// If we are in a replay and have a blended value for playback, use that
POVRot.Pitch = BlendedReplayViewPitch;
}
else
{
// Else use the RemoteViewPitch
POVRot.Pitch = RemoteViewPitch;
POVRot.Pitch = POVRot.Pitch * 360.0f / 255.0f;
UE_LOG(LogTemp, Log, TEXT("dddddddddddd %i"), RemoteViewYaw);
POVRot.Yaw = RemoteViewYaw;
POVRot.Yaw = POVRot.Yaw * 360.0f / 255.0f;
}
}
return POVRot;
}
Finally works magically but I am still confused.
Is it because my coding is wrong or the parent functiong calling statement is wrong?