I am a student in the Technology Student Association (TSA) which is a way to compete and win awards for special tasks. I am making a game which involves falling blocks and i need to climb up the blocks but i cant make the character go back out of the spawn point when the death zone hits him. Please help me make or find a better death zone script.
The 3D platform game tutorial uses "fall out" zones which sounds like what you're after. You need to specify a spawn point and you need to remove the player model when it enters the death zone. Use a box collider set to trigger and enter something like this:
function OnTriggerEnter (other : Collider) {
// destroy all game objects that enter this area
Destroy(other.gameObject);
}
Alternatively you can hide the player character instead of removing it. Then you need to call a respawn function in your player controls script and have a new player created at your spawn point, if the player still exists you just use the translate function to move it back to the spawn point:
transform.position = respawnPosition
http://unity3d.com/support/resources/tutorials/3d-platform-game
Go to page 37
Hope that helps
I am not sure if you have made an object for the death zone but here is a solution. Make a plane (if you don't have one) where the death zone is. You could add this script to the character.
private var dead = false;
function OnControllerColliderHit(hit : ControllerColliderHit) {
if(hit.gameObject.tag == "DEATHZONE")
{
dead = true;
}
function LateUpdate()
{
if(dead)
{
transform.position = Vector3(0,0,0);
gameObject.Find("Main Camera").transform.position = Vector3(0,0,0);
dead = false;
}
}
Just tag your death zone whatever you want it to be called and then replace the tag I put in the script ("DEATHZONE") with the tag you made for the death zone. Change the vector 3 part of the script to the spawn point location.