- Home /
Player Dies when Collide with enemy
I need Help.. please...
See...
I want a behavior that.. when the enemy collides with my player...
My player Dies...
and the player will fall down to the ground... w/ camera facing up when player fell...
PLEEEASE HELP Me :D
Sorry for my poooor english >.<
Answer by AlucardJay · Oct 02, 2012 at 01:04 PM
Unity Scripting Reference has alot of information. Also, a search engine is your friend, especially for what you are asking.
These are the relevant Unity Scripting References for your question :
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html
http://docs.unity3d.com/Documentation/ScriptReference/Object.Destroy.html
some demonstration videos :
http://www.unity3dstudent.com/2010/07/beginner-b01-basic-collision-detection/
http://www.unity3dstudent.com/2010/07/beginner-b13-trigger-collision-detection/
http://www.unity3dstudent.com/2010/07/beginner-b04-destroying-objects/
Here is a list of tutorials to get you going :
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/
this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp
the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials
A list of resources : http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html
Answer by TheNayer25 · Aug 05, 2014 at 07:26 PM
The best idea is : Reset Level with collision. (Horror Game) ? and name this folder JS "LoadLevel". Javascript code :
pragma strict
function OnTriggerEnter (other : Collider) { //check if it's the player that is colliding with this reset object by name/tag or anything else you want if (other.name == "Player") { //do your reset here Application.LoadLevel(Application.loadedLevel); //reset this level. } }
Place this the script in the monster OR an object and (the player has a collision with the moster or object and the result : Restart Game. Hope that helped ! -TheNayer25 / French.