Game Development Reference
In-Depth Information
FIG 6.11 Adding green doors to the maze.
Listing 6.14 Matching the Door with the Key in Order to Open It
. . .
function OnControllerColliderHit (hit : Controller
ColliderHit)
{
if(hit.gameObject.tag == "door")
{
if(hit.gameObject.name == "RedDoor"
&& Camera.main.GetComponent("gui").theRedKey &&
Camera.main.GetComponent("gui").theRedKey.renderer.
enabled)
{
hit.gameObject.GetComponent("opendoor").
open = true;
}
else if(hit.gameObject.name == "GreenDoor" &&
Camera.main.GetComponent("gui").theGreenKey &&
Camera.main.GetComponent("gui").theGreenKey.
renderer.enabled)
Search Nedrilad ::




Custom Search