Game Development Reference
In-Depth Information
In the Hierarchy view, select the first Land Mine game object. Scroll down to the last one, only this
time press and hold the Shift key before you click it. This will select everything in between the first
and last Land Mine game objects in the list. Drag and drop this collection onto the Land Mines game
object. Much better! Save the scene again.
Moving Platform Zone
The moving platform obstacle is good to go as a functional hazard. Just make sure that the player
can get to the moving platform from the “safe” area at the border with the mine field zone.
As you test this, you will find that your cheat code takes you back to the beginning of the minefield.
Time to add a cheat code for testing the moving platform. In the Project panel, open the Assets
➤ Scripts folder. Double-click the Cheats script to open it in MonoDevelop. In the Update()
function, copy the code for the cheat and paste the copy immediately after the closing brace of the
conditional statement. Change this conditional to KeyCode.Alpha2 and the new position to (0, 9, 33.5)
as follows:
function Update () {
if(Input.GetKeyDown(KeyCode.Alpha1)) {
...
}
if(Input.GetKeyDown(KeyCode.Alpha2)) {
if (player != null) {
player.transform.position = Vector3(0, 9, 33.5);
player.gameObject.GetComponent(GoRagdoll).ExitRagdoll();
}
}
}
With this addition you can quickly reposition the player on the far side of the minefield by pressing 2
on the keyboard.
With five zones to go, you can imagine how cluttered the Update() function will get. Time for a little
refactoring. Edit the Cheats script code to the following:
#pragma strict
public var player : GameObject;
private var relocationPoint : Vector3;
function Start () {
player = GameObject.FindWithTag("Player");
}
function Update () {
CheckInput();
}
function CheckInput () {
if(Input.GetKeyDown(KeyCode.Alpha1)) {
 
Search WWH ::




Custom Search