Game Development Reference
In-Depth Information
Add the BeamOn and BeamOff functions:
4.
void BeamOn () {
laserPoint.SetActive(true);
}
void BeamOff () {
laserPoint.SetActive(false);
}
You will also want to make sure the beam is off on startup.
Add the following to the Start function:
5.
BeamOff();
6.
Save the script.
7.
Select the GardenGnome.
8.
Assign the Laser Point object as the Laser Point parameter.
9.
Activate the Cap object.
10.
Click Play, and try activating and deactivating the laser with the 1 and 2 keys.
The laser behaves correctly.
The beam, however, is not very convincing as a sharp-edged, magenta-colored strip. An animated
texture, or more precisely, animated mapping (the offsetting of the UV mapping coordinates), will
improve its appearance greatly. Let's begin by creating a material for the Line Renderer.
1.
Stop Play mode.
2.
From the Chapter 11 Assets folder, Import the SoftEdges texture into the
Game Textures folder.
At the beginning of the chapter, you changed the Default Behavior Mode from 2D back to 3D. On the
off chance you missed this step, you should double-check the texture's import settings.
3.
Make sure it imported as a Texture for its Texture Type.
4.
Check out its alpha channel in the Inspector (Figure 11-28 ).
 
Search WWH ::




Custom Search