How do I change scene with OnTriggerEnter with thrid person controller?

Here’s my script:

//Goes to Level when the player walks through the door

function OnTriggerEnter (other : Collider)
{
    Debug.Log ("OnTriggerEnter : cubeTrigger.tag = " + other.tag); //to show
   tag
    if (other.tag == "transport")
	{
   		Application.LoadLevel ("practiceLevel2");
	}
}

I’ve set a plane with the is trigger box checked in the mesh collider and the set the tag as “transport”. I’ve also made sure my “practiceLevel2” scene is set in my build settings. I’m new.

Is this not working? It looks about right. What is the error?

There's no error, it just doesn't do anything.

2 Answers

2

I guess the problem is object, which you adding this script to.
If it’s player, then your trigger should have “transport” tag assigned to it,
If it’s trigger object, your player should be tagged as “transport”.

Also check if the tag is assigned to the actual object in the inspector.

I have the script attached to the player and the trigger object tagged as "transport". Nothing happens. I tried attaching the script to the trigger object as well and it works in that it'll recognize the collision, but I wanted the tag on the trigger object, so what would the problem be?

function OnControllerColliderHit (hit : ControllerColliderHit)
this above function will work on first/thrid person controller