- Home /
Rigidbody stuck in colliders when moving and ricosheting.
I have simple rocket, velocity is controlled by rigidbody, when it collides geometry it ricoshets with code above:
Vector3 newDirection = Vector3.Reflect(transform.forward,
new Vector3(other.contacts[0].normal.x, transform.position.y, other.contacts[0].normal.z));
//Rotate bullet to new direction
transform.rotation = Quaternion.LookRotation(newDirection);
//add velocity to bullet based on new forward vector
rigidbody.velocity = transform.forward * MoveSpeed;
Everything works, but sometimes bullets just stuck in colliders, tried different interpolation and collision detection setups, but nothing seems to work.
Comment
perhaps show us your colliders with the physics debug - or just their gizmos
It looks like they are missing the OnCollisionEnter event and stuck OnCollisionStay. But that's just a guess.