Game Development Reference
In-Depth Information
You may have noticed at some angles, the beam texture is blurred so much that it goes all the
way to the edges of the line renderer, spoiling the effect of the beam (Figure 11-31 ). This is due to
anisotrophic filtering. Aniso filtering (for short) is what blurs the texture when you are seeing it at a
shallow angle. It helps prevent the shimmering artifacting sometimes seen on ground textures at a
short distance from the player or character. You can increase the Aniso levels for the texture to fix
the problem, but doing so can be expensive resource-wise, so use it carefully.
Figure 11-31. Anisotropic filtering adversely affecting the laser beam
15.
Select the SoftEdges texture in the Project view.
16.
Set its Aniso Level to 4 , and click Apply.
The beam is looking much nicer, but it would look even better if it produced a bit of light where it hit
an object. You will be using the hit position for its location.
1.
Stop Play mode.
2.
Create a new Point Light, and name it Laser Light .
3.
Set its Range to 0.8 , its Color to match the laser beam, and its Intensity to 2 .
4.
In the LaserBeam script, add the following variable:
public Light hitLight; // the light for the end of the laser
Inside the Physics.Raycast conditional, add
5.
hitLight.transform.position = hit.point; // move the light to the hit point
One issue to think about is that as soon as you turn off the laser, the active light will stay where it
was last positioned. But by parenting it to the Laser Point object, it will be activated and deactivated
the same time as the laser beam. Because it is a child of the Laser Point, the code calculating the
offset from the hit point has to use local position to actually place the light.
6.
Save the script.
7.
Assign the Laser Light object to the Hit Light parameter on the Laser Point's
Laser Beam component.
 
Search WWH ::




Custom Search