How to stop a body from losing velocity/bounce so quickly?

Post Reply
jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

How to stop a body from losing velocity/bounce so quickly?

Post by jimjamjack » Sun Apr 16, 2017 11:30 pm

I'm attempting to simulate a "ricochet" effect for the bullets I fire from my gun, but can't seem to get them to behave as intended. Basically, the bullets are rigid bodies with a box shape and the following values:

However, the bullets fly into the scene, bounce quite a bit the first time, then when they hit another surface they stop almost dead in their tracks.

How can I achieve a ricochet effect, where the bullets bounce off of surfaces multiple times and slowly lose their velocity, rather than after about one bounce?

Cheers.
Last edited by jimjamjack on Mon May 01, 2017 9:56 pm, edited 1 time in total.

mpm
Posts: 3
Joined: Mon Apr 17, 2017 12:11 pm

Re: How to stop a body from losing velocity/bounce so quickl

Post by mpm » Mon Apr 17, 2017 12:46 pm

The combined restitution is .4 x .9 = .36, so within the second bounce, not accounting for linear damping, the energy is down to 13% (and by E=0.5mv^2 that is less than 2% of the original velocity) so you need to up the coefficient of restitution.
Have you tried enabling continuous collision detection? The proper calculation of the restitution might depend on the accuracy of the impact velocity, which if calculated conservatively to avoid instability would reduce the bounce effect even more.
From my own experience basing the bounce velocity on the previous frame's velocity makes the simulation much more stable for restitution (especially for resting stacks) with discrete collision detection.

jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

Re: How to stop a body from losing velocity/bounce so quickl

Post by jimjamjack » Mon Apr 17, 2017 4:44 pm

I have continuous collision detection enabled for the bullet body, yes (I should have mentioned that). It's only needed for the moving body and not the static objects it collides with, correct?

As for the restitution, I found information online that stated that anything above 1.0f would result in the body actually never losing momentum (continuing to bounce higher and higher), is that not accurate?
From my own experience basing the bounce velocity on the previous frame's velocity makes the simulation much more stable for restitution
How do you do this exactly? This sounds like a good solution.

mpm
Posts: 3
Joined: Mon Apr 17, 2017 12:11 pm

Re: How to stop a body from losing velocity/bounce so quickl

Post by mpm » Tue Apr 18, 2017 7:00 pm

jimjamjack wrote:
From my own experience basing the bounce velocity on the previous frame's velocity makes the simulation much more stable for restitution
How do you do this exactly? This sounds like a good solution.
Apologies, forgot to emphasize that this is in my own physics engine and not in Bullet. It was done as a trade off to to avoid the bouncing bodies gaining energy from actually impacting early between two steps when using discrete collision detection. It also trades away propagation so Newton's cradle fails.

For Bullet, I think you must increase the restitution, because as I said it is the product of the restitution scalars of the involved bodies that is used for the bounce (when I checked the source code on GitHub). Just keep all scalars below 1.0. Other than that you could also control the bullet's speed manually and count the number of bounces before letting it die off by itself. This is just general advice as I have next to no knowledge of Bullet.

jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

Re: How to stop a body from losing velocity/bounce so quickl

Post by jimjamjack » Tue Apr 18, 2017 10:11 pm

No worries! It looks like playing around with the restitution and velocity until I hit the sweet spot is the way to go about it, unless there's a clever way of playing around with velocity each frame...

Either way, thanks for the suggestions.

Post Reply