Well, i'm making an FPS the map is like a roof, so when you fall and hit the ground, you die, i tried lot's of methods i found here in Unity Answers but none of them worked, so, basicly, when I hit the Terrain(Untagget), the Player Cameras (FPS and Minimap) are disabled, and the DeathCamera is enabled. Well, but this is not my problem, my problem is that, if I use OnTriggerEnter, everything that hits the ground dies, and if I use OnCollisionEnter (them search by tag "Player") nothing happens when i hit the ground.
here's my code, if somebody can help me, thanks a lot, and sorry for my english, i'm from Brazil.
[JAVASCRIPT] Fall.js
#pragma strict
var fpsCamera : Camera;
var minimapCamera : Camera;
var gameoverCamera : Camera;
var skinDead : GUISkin;
var isDead : boolean = false;
function Start(){
fpsCamera.enabled = true;
minimapCamera.enabled = true;
gameoverCamera.enabled = false;
}
function OnCollisionEnter(collision : Collision){
if(collision.gameObject.tag == "Player"){
isDead = true;
DieFunc();
}
}
function DieFunc(){
fpsCamera.enabled = false;
minimapCamera.enabled = false;
gameoverCamera.enabled = true;
yield WaitForSeconds (5);
Application.LoadLevel("#1");
}
function OnGUI(){
GUI.skin = skinDead;
if(isDead){
GUI.Label(Rect(Screen.width /2 -60,Screen.height /2,500,500), "You're Dead");
}
}
(All variables are assigned, removed empty spaces to make the text smaller)
Thanks!
↧