- Home /
How do I change scenes when player falls off the terrain / The player just keep falling
In my scene the player can fall off of the terrain by just keep walking or running to the edge of the terrain . I am trying to switch scene and going into gameover scene.
Answer by Jessespike · Aug 15, 2016 at 05:39 PM
script attached to player GameObject
void Update() {
if (transform.position.y < -100f) {
//TODO Gameover
}
}
Okay. I am not try to ask a stupid question. What does 100f it do ? Is that far or close?
I meant negative 100, I updated answer.
What it means is, when the GameObject's position is vertically below 100 units in world space, then proceed with GameOver. $$anonymous$$ost Characters are usually 2 units tall or so, hope that gives you an idea how much 100 would be. It can be changed, try 10 or something if you want it to be closer.
You can look at a GameObject's or Transform's position from the inspector after selecting it. Create a Cube and move it to get a visual.
I did 100 with the player and it work fine thanks.
Answer by ahbreezy · Aug 16, 2016 at 05:02 AM
An option would be to put a large object to catch him down there and when there is a collision with that object you have you switch scene code.
Your answer
![](https://koobas.hobune.stream/wayback/20220612090854im_/https://answers.unity.com/themes/thub/images/avi.jpg)