1
0
Fork 0

add collision for player

This commit is contained in:
Jan 2018-04-21 19:50:12 +02:00
parent 8a79bd69e9
commit 5c30563dcc
2 changed files with 22 additions and 2 deletions

View file

@ -12,7 +12,7 @@ public abstract class Entity : MonoBehaviour{
} }
// kills the entity // kills the entity
public void Kill() public virtual void Kill()
{ {
if(referringObjective != null) if(referringObjective != null)
referringObjective.Remove (this.gameObject); referringObjective.Remove (this.gameObject);

View file

@ -6,7 +6,27 @@ public class Player : Mob {
public Player() : base(null, 100 ) public Player() : base(null, 100 )
{ {
} }
private void OnCollisionEnter(Collision collision)
{
Debug.Log("Collision");
if (collision.collider.tag == "wall") {
Kill();
}
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "door") {
Debug.Log("Open door");
}
}
public override void Kill()
{
base.Kill();
Destroy(this.gameObject);
}
} }