Frame appears to render in the middle of a game Tick

My first person shooter character’s hand appears to be behind by a frame in some cases

I ran into a very difficult to debug issue and it seems like this is the order of how things happen during a game tick.

ACharacter Tick
APlayerController Tick
ACharacter FaceRotation
APlayerCameraManagerTick
ACharacter CalcCamera

Render Frame??

Some other things happen
AnimBlueprints update

Next Game Tick

So I noticed that if my character’s first person camera component Relative Transform is updated before CalcCamera is called during a tick, my character’s hand is off by a frame. This is visible when my character is crouching and the animation plays smoothly. This leads me to beleive that a frame is rendered some time in the middle of a game tick but the anim blueprints are evaluated next frame before the next game tick. The anim blueprint is where the character’s hands are positioned relative to the eyes via IK.

If I add some safe guards that prevent the camera component from updating during a game tick until after CalcCamera is called, I no longer see any lag of hands being off by a frame during the transition between a character standing and crouching, and vice versa.

Tick

DON’T UPDATE CAMERA COMPONENT TRANSFORM

========================
ACharacter Tick
APlayerController Tick
ACharacter FaceRotation
APlayerCameraManagerTick
ACharacter CalcCamera

========================
Render Frame??

Now update camera component transform:

Some other things happen
AnimBlueprints update

========================
Next Game Tick

IIRC, Animation runs asyncronously now but I could be wrong… though I’m fairly certain that was an optimisation they made for Paragon that made it into UE4. Don’t quote me on that though…

I decided to make my character’s AnimBlueprint call a function on my character to position the camera components. This way, by next game tick when CalcCamera is called it’ll be in the right spot. It’s a bit hacky, but if I find out about any other good places to update the camera I’ll do it there.

CalcCamera is apparently not the right spot to do it.

If I do it like this, hands lag behind by a frame while crouching.



void AWR2Character::CalcCamera(float DeltaTime, struct FMinimalViewInfo& OutResult)
{		
	//position the camera here
	Camera1P->SetRelativeLocation(GetRelativeEyesTransform().GetLocation());
	SpringArm3P->SetRelativeLocation(GetRelativeEyesTransform().GetLocation());

	Super::CalcCamera(DeltaTime, OutResult);
}


If I do it like this, hands don’t lag anymore, but there’s a single frame right when the character crouches where the camera snaps to a different location because the capsule resized.



void AWR2Character::CalcCamera(float DeltaTime, struct FMinimalViewInfo& OutResult)
{	
	Super::CalcCamera(DeltaTime, OutResult);

        //position the camera here
	Camera1P->SetRelativeLocation(GetRelativeEyesTransform().GetLocation());
	SpringArm3P->SetRelativeLocation(GetRelativeEyesTransform().GetLocation());
}