Size and distance relationship

This could potentially be very easy, because the LOD system knows the percentage of the screen that a mesh is currently filling. Now, I have no idea how or if you can hijack this somehow, so I’m just throwing it in here as a possible area to research. If it’s accessible data, it could be a very clean solution.

Hello,

I have the UMG widget target indicator,

I need to change its size depending on the distance to the object (something like height and distance relationship)

Widget should always be the same size as the object.

How can I do that ? What is the formula for this ?

Thanks!

52886-targetindicator.png

The way to do this is to calculate the bounds of the object. Then project those bounds into screen space. Then draw the overlay based upon the projected bounds.

I found a simple formula for this. In NativeTick:

	float distance = (Player->GetTargetLocation() - Box->GetActorLocation()).Size();

	if (distance > 800) // the distance at which the stop resize
	{
		scaleRatio = 1 / distance * 1000;
	}

	OnscreenMarker->SetRenderScale(FVector2D(scaleRatio, scaleRatio));

53020-sc.png

That won’t handle different aspect ratios or different fov settings. To handle it in those cases you have to project the box into screen space. Secondly, the size function is the 3d size so long boxes extruded away from view will have too large of a scaled overlay