Download

UMG Sprite positioning suddenly not working

Heya,

I have a simple UMG setup which takes a sprite and positions it on top of an actor in screen space. This worked great until this morning when I transferred the project to my work PC (same engine version). This is my setup:

bf524c8a4399882b744df7e833308e1bcc114d31.png

32ac811457df025e37d59423446cc77a55abba7c.png

And my newly very much not centered result:

EDIT:

I meant to post this in the BP section, had the wrong tab open. -_- Can someone please move it? Thanks in advance!
Any idea what might be going on? Are there some resolution settings that might have screwed it up? (Both PCs run at 1920x1080)

So, I figured out what was going on. If anyone in the future comes across this and has a similar issue, perhaps goes through a headache or two like I did, behold the source of your pain:

The automatic engine performance thingy set the resolution scale to 75% and the position isn’t being calculated properly.

In 4.8, this is the code we use to calculate where to place widgets in the viewport that are set to Space: Screen on WidgetComponents, if you’d like to make yourself a utility C++ function.



FVector2D ScreenLocation;
bool bProjected = PlayerController->ProjectWorldLocationToScreen(WorldLocation, ScreenLocation);

if ( bProjected )
{
	// If the user has configured a resolution quality we need to multiply
	// the pixels by the resolution quality to arrive at the true position in
	// the viewport, as the rendered image will be stretched to fill whatever
	// size the viewport is at.
	Scalability::FQualityLevels ScalabilityQuality = Scalability::GetQualityLevels();
	float QualityScale = ( ScalabilityQuality.ResolutionQuality / 100.0f );

	Widget->SetPositionInViewport(ScreenLocation / QualityScale);
}

Thanks Nick, that will fix the issue I was having. For now I just set my Editor to not downscale resolution. Thanks for the update!