Download

Actor-related widget screen-space placing

Hi! I have some actor and I want to put a widget near that actor on the screen in C++. For example, I want to put a target box around tha actor.
Is there’s a built’in functionality for such kinds of things in the UE4 out-of-box?
I added UWidgetComponent for that actor.
Now I have the following questions:

  1. How to calculate screen-space bounds of an actor?
  • Calculating Bounds is trivial (using the GetActorBounds() function), however it’s NOT necessary VISIBLE bounds.
  • I know how to calculate World-space VISIBLE bounds of an actor:
    Iterate over all VISIBLE PRIMITIVE components, usr the + operator of the FBoxSphereBounds to accumulate the VISIBLE bounds,
    (Is there a better way?);
  • But - how to project the FBoxSphereBounds on the Screen and find the screen-space bounds?
    I only can PROJECT ALL 8 points and find Min and Max by each coordinate of all points,
    using UPlayerController::ProjectWorldLocationToScreen.
    Is there a better approach? Maybe a built-in function?
  • There’a problem with a projection function UPlayerController::ProjectWorldLocationToScreen(WorldLocation, ScreenLocation):
    It may fail (by returning false) when point to project is INVISIBLE? What to do in that case?
    How can I clip the actor’s world-space bounding volume by the camera’s bounding volume?
  1. How to set for the UWidgetComponent:
  • I know there’s function SetDrawSize to set the size, but how to set the screen-space POSITION, where the widget will be displayed exactly?