Ray visible in Game like in editor

Marc49 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 2

Hi, I succeed with ray in play and also to see in editor but no line from origin to hit in the game...

Thanks for help Marc

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Bolt 2

With "On Draw Gizmo" you can run bolt flow machines in the editor.
There is also a Debug Ray node but I never used it really.
I prefer the line renderer for every kind of ray visualization.
Here I set the point at position 0 in the line renderer array to the position of the camera with a small offset (just for cosmetics). Position 1, which is the second point is set to the position where the raycast hits an collider. 

And when you use a normal ray, keep in mind, that it is only a start and endpoint. To make it visible you have to use some graphic elements like the line renderer or you can stretch some meshes. But a ray is always invisible for the camera.


Debug: Draw Ray is actually perfect for ray visualization, I highly recommend it! It doesn't even have to be in an OnDrawGizmos event and it can stay on screen for a longer duration than just the current frame if you need.

EDIT: Ah sorry, misread your question, you want to see it in game. In that case, I recommend using a Line Renderer component and adjusting the points at runtime to match your ray's origin and destination.