ConvertWorldLocationToScreenLocation frame lag?

I have a UserWidget with an Event Tick function and I am using the blueprint node ConvertWorldLocationToScreenLocation on a static actor location then [Set Position in Viewport] on widget – when I run the game and shake the FPS camera up/down or left/right the widget appears to lag behind by a frame. The problem is very noticeable if I add a DrawDebugString() to the same actor. The distance between the widget and the text will vary while the head moves then stabilize when the head stops. Looking at the code for DrawDebugString() it seems to delay the Canvas->Project() until just before rendering.

My character class has a UCameraComponent attached to the CapsuleComponent which I think is pretty standard.

I’m not sure if I need change the TickGroup of something… FSlateApplication::Tick() seems to be called very late already.

Has anyone heard of this issue before… any suggestions?

Paul

I have discovered a work-around that seems hacky.

Using APlayerController::ProjectWorldLocationToScreen() from ACharacter::Tick() produces bad results.
Internally it uses PlayerCameraManager which relies on something called CameraCache which is not updated until TG_PostPhysics.
I am hesitant to move our entire character class to a later TickGroup.
I discovered that I can override APlayerController::GetPlayerViewpoint() and not use the PlayerCameraManager but just use the controller rotation etc. which is updated immedately after input.

void AMyPlayerController::GetPlayerViewPoint(FVector& out_Location, FRotator& out_Rotation) const
{
Super::GetPlayerViewPoint(out_Locatoin, out_Rotation);

if (!IsInState(NAME_Spectating))
{
	out_Rotation = this->GetControlRotation();
}

}

With this I can call ProjectWorldLocationToScreen() and get accurate values.
This works because I know my camera uses bUsePawnControlRotation.

None of that would be necessary if Widgets had a native Event that occured after PostPhysics but before the frame was rendered.

Here’s my understanding of the order of events:

TG_PrePhysics (0)
PlayerController::PlayerTick() => movement & rotation
Character::Tick() => (calculate screen position with controller view info)
TG_PostPhysics (6)
PlayerCameraManager::UpdateCamera()
FillCameraCache()

Render

FSlateApplicatoin::Tick() => calculating screen position here is too late

Thoughts?

Paul

Another work-around highlights the fact that the Widget default Tick event is questionable.

You can add a SecondaryActorTick to your Character class and set it to TG_PostUpdateWork – this ensure that it is AFTER the TG_PostPhysics update used by the PlayerCameraManager

If you bind that custom event SecondaryTick in your Widget blueprint and use that instead of Event Tick – then you can use the standard ConvertWorldLocationToScreenLocation blueprint node and it will produce screen coordinates in synch with the latest camera movement.

It would be nice if you could just configure the Tick Group for User Widgets – if that is not a viable default for all widgets.