- Home /
Question by
Scandaimos · Apr 30 at 08:14 PM ·
collision
OnCollisionExit dont working
I trying to make a Bubble Shooter game, my bubbles freezes all your transform position when collide with some tags, but i want this bubbles fall when nothing touching it, to stop my bubbles float in scenario and just make it fall to the ground. I use OnCollisionEnter to make it, and trying to use OnCollisionExit, but didnt work, any idea?
private void OnCollisionEnter(Collision collision) {
if(collision.gameObject.tag == "Blue" || collision.gameObject.tag == "Red" || collision.gameObject.tag == "Green" || collision.gameObject.tag == "Yellow" || collision.gameObject.tag == "Roof") {
_rigidbody.constraints = RigidbodyConstraints.FreezeAll;
_shootProjectile.GetComponent<ShootProjectile>().ShowNext();
}
else if(collision.gameObject.tag == "Destroy") {
StartCoroutine(DestroyOnGround());
}
else {
_rigidbody.constraints = RigidbodyConstraints.None;
_rigidbody.useGravity = true;
}
}
private void OnCollisionExit(Collision collision) {
_rigidbody.constraints = RigidbodyConstraints.None;
_rigidbody.useGravity = true;
}
Comment
Your answer
