void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Enemy") { if (anim.GetBool("falling")) { FrogAI frog = collision.gameObject.GetComponent <FrogAI>(); frog.DeathAnim(); } else { isHurt = true; anim.SetBool("hurt", true); audioHurt.Play(); if (transform.position.x < collision.gameObject.transform.position.x) { rb.velocity = new Vector2(-HurtForce, rb.velocity.y); } else { rb.velocity = new Vector2(HurtForce, rb.velocity.y); } } } }
// Use this for initialization void Start() { frog = new FrogAI(-1, 0, false); }