Game Development Reference
In-Depth Information
Figure 14.1 Visual debugging
shows a ray from a raycasting
function.
Second, we will use raycasting for firing Aegis's pistol. After the power is
restored, the security cameras will be on in the base and the player will need
to take these out with his pistol. Using raycasting we will “fire” bullets that will
affect and destroy the cameras. With raycasting we will avoid the problems
previously discussed inherent in actually using a projectile moving through
space at a high velocity.
Finally, we are going to use raycasting to give us hints on placing an object.
Among Aegis's tool kit is an electromagnetic pulse mine that the player
will use to disable the EntryWay electronic lock. Using raycasting we will
instantiate (create in game) an object that will show the player where he
potentially can mount the device.
Lots of fun stuff to do with raycasting once the mechanics of it are realized.
Let's get to it.
But First . . . a Few Notes on Scripting and Help
Up to this point, the scripts we have written have been pretty straightforward
and fairly short. However, as our scripts begin to increase in length it's
worthwhile to note some practices that we should be following as we work.
Comments via //
Scripting languages provide mechanisms to help document scripts as they
are written right within the script itself. JavaScript (along with some other
languages) allow comments to be injected anywhere as long as there is a //
before the comment. Whenever Unity sees // it ignores whatever comes after
that until it reaches the end of a line (where you press Enter). It just takes a
moment to notate the script you are writing, but can save tons of time when
it comes to trying to figure out what you were thinking when the script is
accessed later in the project.
Search WWH ::




Custom Search