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
|
// kills the entity
|
||||||
public void Kill()
|
public virtual void Kill()
|
||||||
{
|
{
|
||||||
if(referringObjective != null)
|
if(referringObjective != null)
|
||||||
referringObjective.Remove (this.gameObject);
|
referringObjective.Remove (this.gameObject);
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue