I followed tutorials, so why doesn't my aim offset replication work?

Basically, this is what I get when trying to replicate aim offsets over the network:

This is from the perspective of the client when viewing the server player. The twitching is caused by the RInterp rotating the character’s aim back and forth very quickly between two points, one of which is the correct direction (I could tell on my other screen as I moved the mouse) and the other appears to be the 90 or -90 degree angle that I’m clamping the animation to. I moved around a little bit too, because the clamp seems to be relative to the client perspective, perhaps; you can see early on that it’s more relaxed about one of the angles I aim at until I move. My character tick function (the relevant section, anyway) looks like this:

FRotator controlRotation = this->GetControlRotation();

FRotator actorRotation = this->GetActorRotation();

FRotator rotatorDiff = controlRotation - actorRotation;

FRotator normalizedRotatorDiff = rotatorDiff.GetNormalized();

FRotator newRotation = FMath::RInterpTo(FRotator(AimPitch, AimYaw, 0.0f), rotatorDiff, DeltaTime, 15.0f);

this->AimPitch = FMath::ClampAngle(newRotation.Pitch, -90.0f, 90.0f);

this->AimYaw = FMath::ClampAngle(newRotation.Yaw, -90.0f, 90.0f);

if(Role != ROLE_Authority)

{

	this->SetAimPitch(this->AimPitch);
	this->SetAimYaw(this->AimYaw);

}

And then the anim graph portion is


. What is causing that aim offset to reset every tick? Or am I totally off as to the cause of this problem?

Found the solution. It’s here, as GoatOfDeath’s solution toward the bottom. The key is to put all pitch/yaw calculation logic in the input sections for turning and looking up, not making any server calls there. Then, every tick, call a function that sets the pitch and yaw on the server.

1 Like