Unity tutorial: script a laser with LineRenderer

Опубликовано: 17 Март 2026
на канале: Red Hen dev
4,774
66

Use the mouse to aim a laser, drawn with Unity's line renderer (LineRenderer component). Then, we add a Raycast to collide with terrain and objects.

Code here: https://github.com/RedHenDev/Unity_sc...

I show you how to add a LineRenderer component, change the width of the line, set a start and end point, and convert the mouse screen position to a world position in 3D space.

We also use a Raycast to determine a correct line of sight for the laser, as well as using this to add a force to any object with a Rigidbody that the laser (Physics Ray) collides with.

Thanks for watching!