- Home /
Change scene using Colliders
I am trying to change scene when the player reaches a ladder. The ladders prefab name is "exit", the FPS's hierarchy name is "First Person Controller", the scene I am in is called "Game" and the next scene is called "End Scene". There is also currently an invisible capsule collider to be used as a collision trigger called "collider". I have searched in multiple questions and the unity coding guide but I have not found any solution. I attempted OnTriggerEnter and OnCollisionEnter.
Answer by Cataclysm Entertainment · Jun 14, 2014 at 09:40 AM
Hi DolphinDudeOne, to do that, it's very simple : you have just to use OnTriggerEnter and a tag condition, next you call Application.LoadLevel(); and it's done. In your case, it's like that : var levelName : String; function OnTriggerEnter (collider : Collider) { if (collider.tag == "tag of your capsule collider") { Application.loadLevel(levelName); } }
But if you want to keep your fpsController, add a script that prevent the fpsController destruction, like that function Awake () { DontDestroyOnLoad (transform.gameObject); }
See here and here, it's the scripting API documentation.
Sorry if I'm not good in english, i'm french...
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Make a hole in object? 1 Answer
collision combo 1 Answer
raycasts only working with IsTrigger colliders? 1 Answer
How to load a scene on collision 2 Answers