Lazer measurment

Hey,

I’m beginner with blueprint and trying to create a lazer mesurme blueprint that would give constant distance measurment to surface where it hits.

like they have in this video attached to the car.

I found this blueprint which gives me the distance as printed string but how I can get it as meters showing next to the “lazer”?

#4-27

Thanks!

You can try this…

These are the three base numbers you need to calculate:

image

  • LocationOriginVector: the start location of the trace.
  • LaserYaw: We will use this to rotate / aim the laser in the XY plane.
  • DirectionVector: It’s the resulting vector that will give the direction of the trace.

For reference this is the blueprint hierarchy:
image


This is for the Line Trace Start and End:

To place the widget at the center of the trace, I did the following:

  • You need th break the Out Hit and divide Distance / 2., then multiply it by the DirectionVector + LocationOriginVector to place it half of the line trace.
  • You also need to rotate it with the trace; for this we use LaserYaw.

DistanceTrace

Setting it up this way allows you to do this:
image
DistanceTraceRotate

With a bit more time you can create a function that can spawn multiple widgets and distribute them like in the video.

Hope it helps. Let me know if you have any questions.

4 Likes

Thank you pezzott1 for the answer!

I had finally time to try it by myself. I was able to follow other ways your instractions but how did you create the DistanceTextComponent -DistanceWidget?

and thank you for detailed breakdown of BP!

Sweet. Math nodes! Is this for an upcoming project of yours perchance? :eyes:

1 Like

I’m using UE for previs in a smaller scale than in the reference video. Trying to develope similar tools.

Yes… testing how people react to it :grimacing:

1 Like

DistanceTextComponent is a Scene Component I used for the position and rotation. It is not a widget… just noticed it has same icon.

If you notice on the second gif when I’m only rotating the trace, the Distance text is always on the side towards the front of the cube. That is because i rotate it 180 locally relative to its parent using dot product to know on what side it is. Did not share that part because it was just me having some fun… :wink: