Enhancing the laser aim with a Line Renderer
Let's improve the previous recipe by displaying a laser beam from the character's laser gun to the projected laser target. We'll implement the laser beam through scripting a Line Renderer
, which is being redrawn each frame:

Getting ready
This recipe is based on the previous one, so make a copy of that project and work with its copy. You'll also need a Texture for the beam color; one is provided in the 07_05
folder called beam.psd
.
How to do it...
To enhance the laser aim with a Line Renderer
, follow these steps:
- Our
Line Renderer
will need a Material to work with. Create a new Material namedm_beam
. - In the Inspector, set the
Shader
of them_beam
toParticles/Additive
. Also, set its Tint Color to red (RGB:255;0;0
). - Import the beam image file. Then, set it as the
Particle
Texture for them_beam
, as follows:

- Create a new C# script class named
LaserBeam
, and add an instance object as a component to the Game Object's Laser Projector:
public class LaserBeam...