Game Development Reference
In-Depth Information
FIG 6.16 Positioning a cube in front of the factory door.
Listing 6.19 Using a Trigger Event to Teleport to Another Scene
function OnTriggerEnter (obj : Collider)
{
if(obj.gameObject.tag == "toSewer")
{
Application.LoadLevel("sewerScene");
}
}
Step 7. Select File > Build Settings from the main menu and add the
outside and sewerScene scenes to the Scenes in Build box by dragging
them from the Project.
Step 8. Play. Walk up to the factory door and you will be teleported
into the sewer room. You could add any number of doors in this
way to your game by giving each one its own tag and sending the
player to a different scene using if statements in the OnTriggerEnter()
function.
Search Nedrilad ::




Custom Search