- Home /
Vertical distance indication
Hi, I have been trying to implement a code where I can show an arrow (or maybe a raycast) indicating the vertical distance between two objects. Any help will be appreciated.
Thanks.
Do you want to show the distance in the Editor, or in play mode / build? These require different approaches. What would you like to do if there is no overlap between their vertical projections (i.e. not directly above each other)? Also, do you just want to draw a line segment, or an actual arrow?
The general approach for this would be to deter$$anonymous$$e the start and end position for your distance marker, taking into consideration the extents of your objects both in y coordinate and xz plane. Then use these values to set up a line segment with the same values for x and z coordinates, but different for y.
Hi @Harinezumi
I want to show it in the Play mode and an actual arrow is not necessary. Furthermore, it not necessary for the two items to be directly under each other.
Answer by aanu · Jul 12, 2018 at 06:29 PM
This is how I got it to work:
I follow the example this YouTube video (https://www.youtube.com/watch?v=km_kU-j7mcw) and I it is close to what I want so I stick with it
I'm glad you figured it out!
For play mode line drawing, I also would use a LineRenderer
, or if you want a very thin line, (just 1 pixel) then use OpenGL draw mode (see the example in scripting reference).