Game Development Reference
In-Depth Information
Step 17:
Adjust bulkhead trigger. In the last chapter on triggers, we set
up the first bulkhead door to open via our trigger. The version we opened
was the baked version because it was just easier to see, but now we need
the Trigger-BulkheadDoor1 to open the door that's in the unbaked version
of Hallway. So select Trigger-BulkheadDoor1 in the Hierarchy this time
and redefine the Door using the version of Hallway_DoorBulkhead_Group
within the unbaked version of Hallway.
Why?
This is actually one of the benefits of making these variables public (as
opposed to using private variables that we populate on a function Start
with a find function). If we have multiple objects named the same thing,
or if we want to make adjustments without having to descend again into
the script, the public variables are there and flexible.
Tips and Tricks
When working with this unlit version of the map, things can be dark,
really dark. Sometimes, when working with a dark scene it can be
very helpful to turn off the lighting in the Scene window. Just turn off
the lighting as shown in
Figure 14.11
and the scene view will show
everything well lit, although the in-game lighting will remain true in the
Game window.
Figure 14.11
Turning off lighting in the Scene window.
Step 18:
Test. The player should be able to walk through the scene and
the bulkhead door should open. Make any other adjustments using
triggers to accommodate this new darker version.
Step 19:
Create a new function that swaps the unlit and lit models. Add
the following to the bottom of AC_ToolFunctionalityScript:
var hallwayBaked: GameObject;
var hallwayDark: GameObject;
function Update () {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform
.forward, hit, 100)){
Debug.DrawLine (transform.position, hit
.point);
Debug.Log (“Selected object is ” + hit
.collider.gameObject.name);