Game Development Reference
In-Depth Information
Fig 4.11 Adding spheres as
waypoints to the waypoint script.
Step 13. Create a new JavaScript file called finishline.js and attach it
to the new cube. Enter the code in Listing 4.20 . This will cause a Game
Over screen to pop open when either car collides with the cube.
Listing 4.20 Call a Game Over screen
private var winner = "";
private var playerLocation: Vector3;
private var npcLocation: Vector3;
function Start()
{
//remember location and orientation of both cars at
//the start
playerLocation = GameObject.Find("Car Prefab").
transform.position;
npcLocation = GameObject.Find("Player2").
transform.position;
}
function OnTriggerEnter(collision: Collider)
{
//if there is no winner yet
if(winner == "")
Search Nedrilad ::




Custom Search