public void OnCollisionEnter2D(Collision2D collider) { if (gameObject.activeSelf) { if (hasLanded) { return; } hasLanded = true; DieBehaviour die = collider.gameObject.GetComponent <DieBehaviour>(); ArrowBehaviour arr = collider.gameObject.GetComponent <ArrowBehaviour>(); if (die != null) { Instantiate(blood, collider.contacts[0].point, Quaternion.identity); die.Kill(" got hit by an arrow"); gameObject.SetActive(false); } if (arr != null) { gameObject.SetActive(false); //Destroy(gameObject); } this.collider.enabled = false; GetComponent <Rigidbody2D>().isKinematic = true; //transform.parent = collider.transform; } }
public void OnTriggerEnter2D(Collider2D collider) { DieBehaviour die = collider.gameObject.GetComponent <DieBehaviour>(); if (blood) { Instantiate(blood, transform.position, Quaternion.identity); } if (die) { die.Kill(deadReason); } }
protected virtual void Awake() { dieBehaviour = GetComponent <DieBehaviour>(); currentHealth = healthData.Health; }