Game Development Reference
In-Depth Information
Figure 15.23 Tightened script with local variables.
function Update () {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform
.forward, hit, 100)){
var hitObj = hit.collider.gameObject;
var hitDir = Quaternion.LookRotation(hit.normal);
if (hitObj.name == “Hallway_PowerPanel_Switch”){
The entire function Update can be tightened up and can look like
Figure 15.23 .
Tutorial 15.5: The EMP Mines
The EMP mines are meant to allow electronic systems to be overloaded
and disabled. They are meant to be mounted on the floor or wall next to an
electronic device, and then when they go off, do their damage and disable
any electronics around them. These are particularly valuable when trying
to get through things like electronic security systems like the one near the
entrance to the base.
Placing things in a game is always an interesting challenge. Different games
have attempted to this in different ways, but among my favorites is how the
engineer works in Team Fortress 2. He sets up turrets. The player playing
the engineer has to decide where the turret is set up and how it is oriented.
The methodology is sort of a ghosted version and blueprint that appears
before the player, which shows where the turret will be placed once the
player activates it. We will use a very similar methodology for this game.
Search WWH ::




Custom Search