Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Apr 16, 2017 11:30 pm 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 39
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.

Top
 Profile  
 
PostPosted: Mon Apr 17, 2017 12:46 pm 
Offline

Joined: Mon Apr 17, 2017 12:11 pm
Posts: 2
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.


Top
 Profile  
 
PostPosted: Mon Apr 17, 2017 4:44 pm 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 39
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?

Quote:
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.


Top
 Profile  
 
PostPosted: Tue Apr 18, 2017 7:00 pm 
Offline

Joined: Mon Apr 17, 2017 12:11 pm
Posts: 2
jimjamjack wrote:
Quote:
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.


Top
 Profile  
 
PostPosted: Tue Apr 18, 2017 10:11 pm 
Offline

Joined: Tue Jan 31, 2017 8:07 pm
Posts: 39
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group