Slow Character Rotation on Client

Hello Everyone,

So i have this problem that i don’t know how to solve:

void AMyCharacter::CharacterTurn(float AxisRate)
{
	if (Controller != NULL && AxisRate)
	{
		// Move the Camera around the Character
		float DeltaYaw = AxisRate * BaseTurnAroundRate * GetWorld()->GetDeltaSeconds();
		AddControllerYawInput(DeltaYaw);

		// Turn the Character on client
		FRotator NewActorRotation = GetActorRotation();
		NewActorRotation.Yaw += DeltaYaw * CastChecked<APlayerController>(Controller)->InputYawScale;
		SetActorRotation(NewActorRotation);

		// Server RPC
		ServerTurn(NewActorRotation);
	}
}

What i want to do with this function is that, when i press the button bound to this function, the character will start rotating, and the camera aswell. At the same speed, so there is no relative movement between the character, and the camera.

If i play the editor as Standalone, everything works just like that.
But if i play the editor as Client, the character will rotate a little bit slower, so eventually the camera will start to circle around the character.

And i just can’t find out why :frowning:

Try NewActorRotation.Yaw += DeltaYaw;
See what happens.

I’ve done that when i wrote that function for the first time, the result was that the rotation speed of the character was even slower, the character looked like he didn’t turn at all (if i didn’t look close enough on the screen :))

Try NewActorRotation.Yaw = CastChecked(Controller)->GetControlRotation().yaw ;
Not sure if this is the right way to call the Get control Rotation but VS should take care of that.

Make the camera be relative to the character, in character coordinate space, and then you only need to rotate the character.

The reason it doesn’t work in networking, is that the camera is directly local, whereas the character will sync with the server which introduces some differences.

Ibelieve that i don’t know how to do that…

The good news is that the transform mode (local versus world) and how to do hierarchies of components and objects is a well documented part of the Unreal Editor (and engine) so it should be pretty easy to read up on that!

Well…

The SpringArm is already attached to Capsule Component as relative, also the camera is attached to the SpringArm in constructor… There shouldn’t be a problem with hierarchy, or transform.

ThirdPersonCameraSpringArm->AttachToComponent(GetCapsuleComponent(), FAttachmentTransformRules::KeepRelativeTransform);
ThirdPersonCamera->SetupAttachment(ThirdPersonCameraSpringArm, USpringArmComponent::SocketName);

Is normal, that for the Server RPC to work, i must run SetActorRotation() first locally?
What i mean is, if i comment that function, the ServerTurn() function will not work…

void AMyCharacter::ServerTurn_Implementation(const FRotator NewRotation)
{	
// Turn the character around (on server side)
SetActorRotation(NewRotation);
}

even when it contains the same SetActorRotation() function.