private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { m_Character.Damage(1); } }
// Update is called once per frame void OnTriggerEnter2D(Collider2D col) { if (col.CompareTag("Player")) { if (!col.gameObject.GetComponent <PlatformerCharacter2D>().invincibility) { player.Damage(1); } StartCoroutine(player.Knockback(0.02f, 50, player.transform.position)); } }
public void DoAttack(int type, BoxCollider2D coll) { // draw circle and see if it intersects with the other player float damage = Random.Range(0f, 20f); print("a"); if (coll.IsTouching(other)) { player = other.GetComponentInParent <PlatformerCharacter2D>(); player.Damage(damage); print("b"); } }
private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Player") { PlatformerCharacter2D player = other.gameObject.GetComponent <PlatformerCharacter2D>(); // Player lands on top of Reddy. if (player.state == State.falling && other.gameObject.transform.position.y > transform.position.y + reddyWorldHeight) { other.gameObject.GetComponent <PlatformerCharacter2D>().Jump(); anim.Play(deathAnim.name); Destroy(gameObject, deathAnim.length); } else { player.Damage(gameObject); } } }