/// <summary> /// When another collider enters ours, we assign our rigidbody's velocity to his. /// </summary> /// <param name="other"></param> private void OnTriggerEnter(Collider other) { Bunny colBunny = other.GetComponent <Bunny>(); //Checking if its a Bunny, with a Rigidbody and that is not moving. if (colBunny != null) { if (other.GetComponent <Rigidbody>() && !colBunny._moving) { if (_rigidbody.velocity.y <= -2) { colBunny.anim.SetTrigger("Squeeze"); colBunny.GetHit(hit: false); } else if (_rigidbody.velocity.magnitude > 2f) { //Send a call to GetHit() which delays for X seconds the Bunny's detection with the real world. //Since the Bunny is already on the floor, it might return true for collision the moment the baseball bat touches it. colBunny.GetHit(hit: true); //Assign our velocity with some changes. I found that it feels better when it's half the force. other.GetComponent <Rigidbody>().velocity = _rigidbody.velocity / 2; } } } }