How can I translate a line trace hit location into points on a UI image?

Hi,

Using EasyBallistics plugin I have a working spread using 50 shot counts.

Now following my hit event, I am trying to reproduce this type of UI shown in this screenshot and I am wondering how I can translate the world position of the shot counts that hit the target (I have their world xyz) into pixel positions or xyz on an image in the UI Widget?

image

Thanks

Hello, Claviateur:

This requires a lot of different skills.

I don’t know what your experience is, but assuming you understand how UI works, then I would look for tutorials on creating maps/minimaps. The concepts are the same. Instead of your map following the position of your character, it would track the position of the collision of your line-trace.

1 Like

Thanks for the help! I am still learning UE / Blueprints but getting interesting results with my learning process.

Ok, I will look at the mini maps to see if I can use the same system for my shot review.

In fact I tried also to spawn a camera near the target at runtime and capture a 2D image but that did not work well .

I will look for tutorials on maps then.

Thanks again!

1 Like

Depending on what you need, there are two ways to project a world location to a screen location. There are C++ and Blueprint calls for both:

World location to absolute screen pixel:

UGameplayStatics::ProjectWorldToScreen | Unreal Engine 5.2 Documentation

World location to UMG DPI position:

UWidgetLayoutLibrary::ProjectWorldLocationToWidgetPosition()

Afaik if you want the relative position within a specific HUD element, you’ll probably have to do that math manually based on the projected HUD position, the HUD element position, the HUD element pivot (top left, center, etc.), and the HUD element size.

you needd to remap one range to another range.

Let’s take the following information:

  • the (center) position of your target.
  • the positions of your spread shots.

You measure the following situation:

  • Shot 1 is 10cm up and 10 cm to the right of the target’s center position.

if you imagine the target’s most left position you want to measure as 0% and the most right position as 100%, you can say the shot is at X % horizontally of the target’s size. Do the same vertically. now you have mapped the shot position to a 0 to 100 range for both X and Y axis. You can use the percentage to modify your UI per shot.

Instead of say spawning a “dot” widget for every shot maybe someone can come up with a fancy shader for the UI. Unreal’s UI is horrible on performance with these kind of things.

Thank you all for the detailed explanations. I need to learn a lot and get into some serious Math :slight_smile:

I wonder if there is a ballistic plugin on the Marketplace that features a shot review option. That would be great