Whats a good way to kill player if they go below a certain area?

I need some advice or some help pointing me in the right direction on how to create a script that would kill off the player if they fell off the course and falling down below a certain point.

So for instance my course is scaled 50 tall on the Y Axis and say I want to kill off the player if they reach below 25 or something like that.

Any advice on how to do that?

I’m still looking around trying to figure this out better though I’m still trying to get the hang of scripting.

Assuming that on the players death you would like to simply restart the game you can do:

function death()
{
Application.LoadLevel(“SceneNameHere”);
}

This is essentially the same as hitting the play button and will start the game from the scene’s start.
If not what are you looking to happen upon death?

First thing first.

1: Take off the camera controller script.
2: Take off the main camera from the player Object.

Second thing to do (and the easiest)

1: create another camera and remove its audio listener.
2: Attach that second camera naming it Player Camera and make it a child of the player ball
3: Position the Player Camera in the angle or view you prefer,

Third thing; Barrier

Different people have different preferences for different styles of games so that is why you are getting confused. Don’t worry about “how they want it.” You need to figure out how things will work for you on the back-end of things.

If you use a barrier as “a point of no return” to kill the player if they fall into that abyss, then you can do something very simple, you just make a flat place, remove the visible aspect of the mesh, name it and tag it barrier, and slap on it something like the script from the Space Shooter game tutorial as;

using UnityEngine;
using System.Collections;

public class Barrier : MonoBehaviour
{
void OnTriggerExit(Collider other)
{
Destroy(other.gameObject);
}
}

All I did here was change the file name as Barrier rather than “DestroyByBoundary.” It does not really matter and in reality the only thing having it listed in player health or destruction or whatever is so that this specific file is found.

Instead of making a whole single box (which also can cause problems like sucking players outside of it or into it soon as you turn the game on), just create a cube, make it flat and transparent and set it however high or low you want it. If you want side barriers, just do the same thing by creating barrier walls.

As far as options, it is again up to you. You can set it up to kill someone if they hit those barriers, or simply restart them back at the starting location, or a combination of the two if you are doing a setup like “how many lives” one has to play before the game is completely over.

If you want the camera to still act as in a following type manner, use the secondary one and reserve the main camera for UI.

If you can pull off a really disturbing feature, when the player hits the barrier from the fall and you set up a scene to be replayed, or you just want to be funny and add something odd instead, you can also have it where if the player hits said barrier to play cut scene before restarting at designated start point.