add collision for player
This commit is contained in:
parent
8a79bd69e9
commit
5c30563dcc
2 changed files with 22 additions and 2 deletions
|
@ -12,7 +12,7 @@ public abstract class Entity : MonoBehaviour{
|
|||
}
|
||||
|
||||
// kills the entity
|
||||
public void Kill()
|
||||
public virtual void Kill()
|
||||
{
|
||||
if(referringObjective != null)
|
||||
referringObjective.Remove (this.gameObject);
|
||||
|
|
|
@ -9,4 +9,24 @@ public class Player : Mob {
|
|||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue