- Home /
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?
Answer by nbg_yalta · Nov 12, 2013 at 01:58 AM
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?
Answer by yogee · Nov 12, 2013 at 04:14 AM
function OnControllerColliderHit (hit : ControllerColliderHit)
this above function will work on first/thrid person controller