RigidBodies keep on sliding,colliding and takes much longer to come to rest.

I have created Angry Birds like game. It has a sling shot that fires projectiles at a castle made of rigid bodies.
what happens is that when i fire projectile from sling shot ,my camera follows it and resets when the ball gets slow, its good according to code (i-e is check “IsSleeping()” condition if true reset camera for next fire)

The problem is when the ball hits castle some times it get stuck in castle rigid bodies, the rigid bodies keeps on slowly sliding to ground and even the ball does not moves faster "The camera does not resets until all rigid bodies collided with ball have completely stopped motion, which takes longer to reset camera.

Kindly tell me some adjustments for this… Thank You

Easiest is to probably add Physic materials with more drag on them, or just turn up the drag on your rigidbodies so they come to rest sooner. Have you tried this approach?

Physics is messy. Whatever else you do, your camera should probably have some kind of timeout where it eventually gives up and resets even if the objects have not stopped moving.

1 Like

Another approach building on what @Antistone said above is to have code to detect the first impact, then start increasing the rigidbody drag in real time until everything stops moving. Once it stops, reset the drag to your base value, whatever that is, clear the boolean you set when you detected first impact, and repeat the cycle with the next fling.

Thanks Kurt, i will try it. Currently i solved it using velocity vector magnitude of ball.

1 Like