Multiple Object Collider Detection to load new scene

Hi,

I am doing a hang glider game, whereby there's 5 rings in a terrain and the objective of the game is to fly through all the FIRST 4 rings first before you can go on to the 5th ring which will then load a new scene(A fast video and then a LEVEL Completed page )

I am currently having only one problem.

My hang glider can detect all individual rings i go through however, how do we set it up so that the NEW SCENE(video...) will only load IF I went through all of the FIRST 4 Rings, not any less. I Tried using public/static var and etc but it wont work as there's an error saying Unknown Identifier.HELP!!!

This is my current script for each of the first 4 ring

var airplane : GameObject; var Ring : GameObject; var ringscore1 : boolean;

ringscore1 = false ;

function OnTriggerEnter (other : Collider) 
{
  var distanceToRing;
  distanceToRing = Vector3.Distance(airplane.transform.position,

transform.position); print ("Distance to Ring: "+distanceToRing); //~ distance check

  ringscore1 = true ;

}

and this is my current script for the 5TH Ring

function OnTriggerEnter (other : Collider) 
{
   if ((ringscore1 == true) && (ringscore2 == true) && (ringscore3 ==

true) && (ringscore4 == true)) { yield WaitForSeconds(3); Application.LoadLevel("scene6Landing"); } }

1 Answer

1

You are trying to access ringscore1...4 in your 5th ring script. I think ringscore1 is in another script so you can't access it through name only. What you have to do is GameObject.Find("Ring1").GetComponent("YourScript").ringscore1

However this is a bit clumsy, so a better idea would to make RingManager script with a bool[5] in it and update that each time one of the rings is hit. You could also put this array in the script for your final ring.