- Home /
This question was
closed Sep 08, 2013 at 03:43 PM by
fafase for the following reason:
Not a question.
Player Die When Hit By Enemy
Do you guys know how to make player die (turn to death scene) when player hit by enemy?
Comment
you need to calculate the distance and angle to the player and if the enemy attacks the load the death scene
Do I need to make trigger on enemy or something? Please explain all of it. I'm really noob at program$$anonymous$$g....
download the "free fantasy ai example" from the asset store you'll find it in Scripting/AI and then look at the scripts they are very useful
Answer by Superwayne · Sep 08, 2013 at 03:35 PM
You can use the OnCollisionEnter function. For c#:
void OnCollisionEnter(Collision col){
if(col.collider.tag == "Enemy"){
Application.LoadLevel("DeathScene"); //name of your death scene
}
}
You just need to create an Enemy tag and tag the enemy object as "Enemy"