Collision vs Trigger [Solved]

Going back to square one… again.

Scenario : I am trying to create a maze. At the end of the maze I made a cube that has a box collider on it. Mesh renderer is not checked. It is sized to the area I want it.

Goal : I’d like to have my character enter the area for the game to end (Called finalOut in hierarchy). Close out on it’s own but before it does the words “Congratulations” appear on the screen.

Problem : I’ve tried collision detection vs triggers. Created layers named the one Finalout attached it to the gameobject finalOut, one named player (attached to player). The basic FPS controls are being used (CharacterMotor, FPSInputController, ETC.) Still nothing works.

Question : For what I’d like to happen should I be using a trigger or just collision?

EDIT
Script :
The script named Trigger_Controller

 public var gameControl : Game_Controller //script that is attached to my player
    
    function OnTriggerEnter ( Other : Collider )
    {
    
        if(other.transform.gameObject.layer==9) 
          //layer nine is named finalOut and on my finalOut game object
        
        //finalOut
        gameControl.finishedTheGame (); 
        //defined in other script
   }

Then this script ^^^ is attached to my GameObject (finalOut)

Thoughts : I’m thinking something to do with the script is wrong. The question is what?

If need be I will post the other one.

Since you want to make the player be able to walk into the invisible box, you’ll use it as a trigger.

Then on your box you’d attach a script that includes this (javascript):

function OnTriggerEnter (other : Collider) {
    if(other.name == "player"){ //this is actually the name of your player GameObject, you can use a tag or layer instead too
      Debug.Log("Congratulations!");//will print it on the console, but you can change it for a screen message 
      yield WaitForSeconds(3); //wait for 3 seconds
      Application.LoadLevel ("Level2"); //load level 2 supposing you just finished level 1
    }
}

I would use OnTriggerEnter as this means that your character wont actually collide with the box, you could use the Collider parameter to check to see if it really is the player which collided. However in this case I don’t think there is much difference.

You could try to use raycasts with a distance.
It holds possibilities to compare tags, …

So, the script is on the exitTrigger and checks to see if it gets hit by another exitTrigger?:

if(other.transform.gameObject.layer==9) 
//layer nine is named finalOut and on my finalOut game object

So it isn’t actually checking if it was hit by the player?

You could move the OnTrigger to the player, and it should work (the player doesn’t need a trigger – OTE also works if you hit a trigger.)

Or, if only the player is moving, you could skip the ifs (if something hits exitTrigger, it must be the player.) More common is to check tags. Tag the player as “Player” and:

Debug.Log("trigger A");
if(other.transform.CompareTag("Player")) {
  Debug.Log("Trigger B");
  // do end round stuff
}

@vagos21

function OnGUI ( )
{

    GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity,
    new Vector3(Screen.width / 1024f, Screen.height / 768f, 1)); //My screen size
    if ( GameEnds )
    {
        GUI.Label(Rect (350,350,350,350), "CONGRATULATIONS! GAME OVER");//Centered on the screen
    }
}

private var GameEnds : boolean;
function OnTriggerEnter (other : Collider) {
    if(other.transform.gameObject.layer==8){ //I had to change to the layer 8 = player
    GameEnds = true;
    yield WaitForSeconds(3);
    Application.Quit (); //nothing happens with this (I think it's b.c. I'm testing in Unity)
    }
}
//attached this whole thing to my GameObject and it worked
//Just need to increase font size and maybe a colour and I'm good

THANKS EVERYONE FOR YOUR HELP. NOW ON TO THE NEXT PART OF MY GAME