How to make a widget that follows the on screen location of an actor (kind of like a lock-on system)

I am trying to make a targeting system for a turn by turn game, i want to create a widget that follows the on screen position to use the “on drag enter” override to determine wich ennemy is targeted by the player, but i don’t know why all my targeting widgets are off.

I suspect the problem is in the maths.

Screen One shows the overlay where i add my targeting widget as child

Screen Two shows the targeting widget logic for the interpolation

Screen Three is the in game result, the pale yellow squares are my targeting widgets, as you can see they are not over the place holder ennemies (the tall rectancgles) as i would want them to.

You probably need to ProjectWorldLocationToWidgetPosition(). There should be a BP equivalent.

UWidgetLayoutLibrary::ProjectWorldLocationToWidgetPosition | Unreal Engine 5.6 Documentation | Epic Developer Community

UMG pixel don’t usually align with physical screen pixels due to DPI and viewport scaling. So when you translate world >> widget you need to adjust for DPI and vice-versa when going widget >> world.

thanks it worked, needed to smooth the visuals a bit but it worked as intended