Hey all I am working on a 3D maze game. I would like to know how i could start and end the levels .
Hi as I said I am working on an 3D maze game,and learning code as i go along as i dont know any apart from a little HTML 5 . I have my levels I just don't know how I could start and end the levels the only code I know what doesn't work is below the text. any help would be great all i need to know is starting a level and ending one/moving to next level. Thanks all.
//Script to revert winning player back to main menu
var levelToLoad : String;
function OnTriggerEnter(hit : Collider) { Application.LoadLevel(levelToLoad); }//END FUNCTION ONTRIGGERENTER
function OnTriggerEnter(other : Collider) { if(other.gameObject.CompareTag("Player")) { Application.LoadLevel("EndLevel"); } },//Script to revert winning player back to main menu
var levelToLoad : String;
function OnTriggerEnter(hit : Collider) { Application.LoadLevel(levelToLoad); }//END FUNCTION ONTRIGGERENTER
Answer by Jessespike · Jan 21, 2016 at 06:57 PM
The code should work.
How are your scene objects?
Both objects (Trigger and Player) should have colliders. The collider on the Trigger object should have "Is Trigger" set to true. Player should have a RigidBody with "Is Kinematic" set to true.
http://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
Your answer
Follow this Question
Related Questions
Camera following player, how do get it to stop after the player falls? 0 Answers
C# 3D Collider Without Fixed Points or use Mesh Filter Instead? 0 Answers
(FIXED) OnTrigger waitforseconds not working. 1 Answer
Can not change isTrigger to true 1 Answer
OnTriggerEnter Issue - Collider problem 0 Answers