- Home /
Im NOT Switching Scenes!! PLEASE HELP!!
So Im trying to make it so that once my character hits the door, it`ll act as a portal and take him to the next scene but its not working. Ive tried OnTriggerEnter and OnCollisionEnter. This is mycurrent code.
function OnControllerColliderHit(other : Collision)
{
if(other.gameObject.name == "Portal1"){
Debug.Log("You are in the Portal");
Application.LoadLevel("MainMenu");
}
}
Have you done a Debug.Log(other.gameObject.name); in your function to check if your character is indeed hitting something?
Yes I have and nothing pops up. $$anonymous$$aybe Im not hitting the object? But I have all my Colliders on
Try using: "Application.LoadLevel(1)" or what ever your main menus number is in the build config. Ins$$anonymous$$d of the name of the level.
No, this is the wrong thing to look at. Levels can be loaded by name or number.
Answer by brag42 · Jul 18, 2013 at 02:29 AM
You mentioned below that you have Colliders on. Do you also have RigidBody on them and at least one set as a Trigger?
Ding Ding Ding! brag42 was right, I didnt have a RigidBody, sorry I cant upvote you but I dont have enough Rep.
Also, you might want to have the logic to check on the portal. Having the player check every single thing they come into contact with is wasteful.
Also, you only need a trigger collider if done that way. ;)
In fact, setting up a layer that only collides with the player would remove the necessity for checking tags, and would prevent anyone but the player from triggering certain events.