Game Development Reference
In-Depth Information
It would be nice to see if you can turn off the garden area before the game starts to see if the
deactivated objects will continue to function properly.
2.
Deactivate the Common Wall 3 and the Garden 1 objects in the Inspector.
3.
Click Play, and drive the GGD back and forth through the gate.
The objects continue to work as expected. The problem is that it will be difficult to work on the
scene with half of it hidden. A better solution is to turn the objects off in the Start function.
4.
Reactivate the Common Wall 3 and the Garden 1 objects.
5.
Create a new C# Script in the Game Scripts folder, and name it HideAtStart .
In its Start function, add the following:
6.
gameObject.SetActive(false); //deactivate the object this script is on
7.
Save the script, and drop it on the Common Wall 3 and the Garden 1 objects.
8.
Click Play, and test the new functionality.
The objects disappear on startup and reappear when you exit Play mode. Feel free to set up the
other GardenGates for occlusion culling or disable the box collider that opens the doors.
Game Functionality
With the static part of the environment working well, you can concentrate on the dynamic elements.
The most obvious is the main character, the Gnomatic Garden Defender. The drawback to using
objects that can occlude sections of the environment is that third-person cameras will usually go
through them at some point, as you probably noticed as you drove the d back and forth.
You will also be adding the protagonists of the story as well as fleshing out the environment with the
help of a few more scripts.
Camera Refinements
You probably noticed that the third-person camera is fine until the Gnomatic Garden Defender
goes through the gateway. At that point, it clips the top of the Gateway. One solution is to change
Distance and Height values on the Smooth Follow component when the Gnomatic Garden Defender
triggers the gates. It's a bit abrupt, but it is a simple solution. The first thing to do is get access to the
Camera's SmoothFollow component.
1.
Open the SensorDoors script.
2.
Add the following variable below the existing ones:
public SmoothFollow follow; // the camera' SmoothFollow script
 
Search WWH ::




Custom Search