Hi, I have a problem. See, I’m trying to make it so that when you fall in water, you die. (I don’t have Unity Pro, so I’m just using the simple water thing, adding an object under it.) Here’s the script I have:
function OnCollisionEnter(death:Collision)
{
Debug.Log("Collide with thing");
if(death.gameObject.tag == "Enemy")
{
Debug.Log("DIE");
Application.LoadLevel("dead");
}
}
Does anyone know what the problem is, and how to fix it? The object DOES have the Enemy tag. Also, this script does work with other things, like the enemies that run towards you.
does "Collide with thing" run? does the water itself have collider by accident? does the object with the enemy-tag have Is trigger UNchecked? Is Enemy tag Spelled correctly(copy and paste it) (trust me it can really fool you around)
function OnTriggerEnter (other : Collider) {
Debug.Log("Collide with thing");
if(death.gameObject.tag == "Enemy") {
Debug.Log("DIE");
Application.LoadLevel("dead");
}
}
this should help this is in JS
For this to work, the water plane must be a trigger and must have this script attached, and the character must be a CharacterController or a rigidbody.
Most likely, your player’s collider’s “Is Trigger” is checked, for the sake of other functions in your game. When IsTrigger is checked, none of the OnCollision functions are called–instead, “OnTriggerEnter”, “OnTriggerStay” and “OnTriggerExit” are called.
does "Collide with thing" run? does the water itself have collider by accident? does the object with the enemy-tag have Is trigger UNchecked? Is Enemy tag Spelled correctly(copy and paste it) (trust me it can really fool you around)
– Fornoreason1000I've checked and rechecked everything on that list. I'm so confuuuuuused! Oh, and no, "Collide with thing" doesn't run.
– Teledoor24Using character controller? Any rigidbodies involved?
– meat5000Where is this script attached? Is the water trigger? Does your guy have a rigidbody, even isKinematic?
– fafase