Best way to draw a box around an actor

Whats the best way to draw a box around an actor?

Ive tried using widget components and it works but the scale of the box changes depending on distance from the actor.

I would like to do it in c++ but can use widgets if needed. Ive also tried to use GetActorBounds along with ProjectWorldLocationToScreen to try and determine screen space bounds and draw a rect in DrawHUD()

So far i have not had success in c++ or using widgets.

Mainly I’m trying to draw a rectangle and some text around an object that can be picked up by the player

This sounds good, if you can let the widget component check for distance to the player camera you can set a Width + Height on a sizebox widget on Tick to become smaller when the player is further away. If the content doesn’t scale to fit the SizeBox widget you can combine it with the ScaleBox widget.

Scaling the widget based on distance sort of worked, i also found a way to calculate the bounds in 2d space in c++ here https://forums.unrealengine.com/t/scene-actors-bounding-square-screen-space/459787/23

Ended up using the c++ method and drawing the texture to scale directly in DrawHUD() so the scaling is perfect regardless of distance

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.