private void OnTriggerEnter2D(Collider2D other) { if (!attacking) { if (other.CompareTag("TallGrass")) { speed *= -1; rb.velocity = new Vector2(speed, 0.0f); //sr.flipX = !sr.flipX; Vector3 scale = transform.localScale; scale.x *= -1; transform.localScale = scale; } if (other.CompareTag("Player")) { worm = other.GetComponentInParent <Worm>(); if (worm.active) { attacking = true; anim.Play("Attack"); rb.velocity = Vector3.zero; if (worm != null) { worm.Die("Oh no! A Blue Jay ate Twinchworm!", worm.colorBad); } StartCoroutine(Fly()); } } } }
private void OnTriggerStay2D(Collider2D other) { if (other.CompareTag("Turtle")) { mover.OnTurtle(other.transform); worm.GetOnTurtle(other.transform); } else if (other.CompareTag("Water")) { if (!worm.isDead && !worm.onTurtle && !mover.isMoving) { worm.Die("Twinchworm does NOT like the water!", worm.colorWater); } } }