Light up nearest point of a curved LED-bar to player

Hey All, im looking for an easy way to light up an LED-Bar at the closest point to the player.
It should work with straight or curved LED-Bars.

My first bet would be to use the “find location closest to world location” to find the closest point on a spline. Im unsure on how to use that location to light up the Led-bar.

You may need to explain how this part works. What are they? Light components? Particles? Material? Widgets? Emissive static mesh? Something else?

That are TWO tasks mixed together:

  • finding closest LED point
  • lighting it up.

To find closest, most brute force way is to make array of locations of LED in local space of player (or just distance vectors from player to LED) then sorting them by length, or for loop and remembering shortest.

Another way find closest column, then closest LED in that column. (If panel is bent only in one axis)

How do you lit one LED you want? That depends how you make them lit or unlit.
With dynamic material instance, you can just tell closest panel, to swap material to lit.

You can also look into that look into UI material Examples on marketplace/fab. There is nice LED material, some functions to create it etc. It can be modified to lit LED Cells around UV coordinates.

Hey, thanks for the reply. Im open to all of the suggestions you named. The LED part ist not important at all. So the goal is just to show the nearest point of a curved object to the player.

Currently I have a widget as a texture on a static mesh. My idea was to move a rectangle on the widget in relation to the position of the player.

(I implemented the widget as a texture similar to this video: https://www.youtube.com/watch?v=37UmUAdIHss&list=PL1SfvJEKrKE6sD6a2sFmZt3EDzIx_WnC_&index=61&t=874s)

Im unsure if the widget is the best approach. I haven’t found any similar project.

You can use line trace, and record points where it hits mesh.

Now how to get array of points that you can line trace to:

Easiest would be to make that static mesh into blueprint actor, then calculate grid of points in mesh local space.

If not you can try angles for vector. But this is a bit of vector math.

  • first you need boundaries for that mesh. So either use trigonometry to find angle ranges, or just “scan” around and remember what angles get hits.
  • when you have range, just make as much steps as you want, do line trace to points on surface of mesh, remember shortest.

However if its flat mesh you can solve closest point with just trigonometry or few vector operations.