- Home /
How Do I change the scene when my character falls into the ocean?
Hey guys, I'm creating a game and when my first person controller reaches the ocean the scene doesn't change to the lost screen. Please help me!
Heres my script which I attached to my first person controller
function OnCollisionEnter(myCollision : Collision) {
if(myCollision.gameObject.name == "Floor")
{
Application.LoadLevel("Lost Screen");
}
}
,
Answer by Romano185 · Sep 02, 2012 at 07:04 PM
Why don't you use :
function OnTriggerEnter (otherobj : Collider){
if(myCollision.gameObject.name == "Player"){
Application.LoadLevel("Lost Screen")
}
}
I don't know what the difference is between a trigger and a collider, but I usually use triggers. Also make sure the object you call Floor has at least a collider. If it still doesn't work try adding a rigidbody to one of the two object. And another problem, you made your player the trigger, not the object you're supposed to touch. Most people want their player to touch multiple triggers. So just to summarize it for you:
Use triggers instead of collision
Attach your trigger to the object you want your player to react with, not to the player itself
Make sure both objects have a collider, probably a mesh collider but another shape is possible too
If it still doesn't work, give your player a rigidbody component
Your answer
![](https://koobas.hobune.stream/wayback/20220613080526im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Overlap Detection HELP!! 0 Answers
Check if an object is at a relative position? 2 Answers
Analysing player metrics help 0 Answers
Damage on collision problems... 0 Answers