- Home /
Question by
Smart Genius · Nov 26, 2012 at 01:12 AM ·
androidgameoncollisionenter
How do I use OnCollisionEnter?
Hi. I am a n00b programmer and I am making a platform game on Android. I want to make it so that when the player touches a special platform, the next scene appears. I have tried to use OnCollisionEnter with no luck. Can someone instruct me VERY specifically on how to do this?
Comment
Answer by aldonaletto · Nov 26, 2012 at 01:28 AM
You should use a trigger instead: create a cube (the trigger volume), child it to the platform and adjust its dimensions/rotation/position; mark Is Trigger in its collider, delete the Mesh Renderer component to make it invisible and attach the following script:
var level: String; // define the level name in the Inspector
function OnTriggerEnter(other: Collider){
if (other.tag == "Player"){ // remember to tag the player!
Application.LoadLevel(level);
}
}