private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Platform")) { playerDeath.Death(); } }
void Update() { if (canMove == true) { heroAnim.SetBool("isRunning", true); if (movingRight == true) { transform.position = Vector2.MoveTowards(transform.position, positions[0].position, speed * Time.deltaTime); } else { transform.position = Vector2.MoveTowards(transform.position, positions[1].position, speed * Time.deltaTime); } if (transform.position == positions[0].position && movingRight == true) { movingRight = false; } else if (transform.position == positions[1].position && movingRight == false) { movingRight = true; } if (hp <= 0) { death.Death(); } } else { heroAnim.SetBool("isRunning", false); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Obstacle") { anim.SetTrigger("Dead"); playerDeath.Death(); } }