Город МОСКОВСКИЙ
00:31:30

Unity tutorial: script a laser with LineRenderer

Аватар
Мир диких пленников
Просмотры:
22
Дата загрузки:
06.02.2025 08:34
Длительность:
00:31:30
Категория:
Обучение

Описание

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_scripts/blob/master/Drone_pilot/rayGun.cs

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!

Рекомендуемые видео