1
votes

I'm trying to make a basic first person shooter game with Bullet and OpenGL. I'm having the issue of my rigid bodies not colliding at high speed.

My bullets will go straight through any other rigid bodies that I have, such as walls. Reducing velocity to less than 10 does result in collisions, but this is too low for a moving bullet. The bullet also moves insanely fast (I know it's a fast moving bullet, but sometimes I can't even see it, not sure if that's expected).

I'm thinking that it's to do with how I'm stepping the simulation? Reading up on it has left me confused. How can I make it so that my objects will always collide (at least, when going reasonably fast), and if possible, is there a way to slow the simulation down whilst maintaining the correct bullet velocity etc. so that I can actually see the bullet moving and colliding?

1
Is this in Unity?Glen Pierce
How are you detecting collisions in the code?Seth Difley
Not in Unity, just c++ code using OpenGL and Bullet. And for detecting collisions, I'm simply letting Bullet handle it, I don't have collision flags. I believe Bullet handles collision by default (look at Bullet's falling sphere tutorial), and my bullets do collide with walls, floors etc. when travelling relatively slowly (They'll fall to the floor and rest on the floor rigid body for example)Jack Phipps
Your bullet is probably travelling so fast that on each frame, it's either too early to collide with the surface or too late. A solution would be to check if the bullet will collide with a surface before the next time it's position is going to be recalculated.Glen Pierce
That sounds like a possible solution. How would I check that with Bullet? Currently I have no test for collisions and my bullet simply moves due to setting it's linear velocity when it's created.Jack Phipps

1 Answers

1
votes

Here are some approaches to solve:-
It is copied from How can I avoid missing collisions for fast moving objects? - an official FAQ

  • smaller timesteps
  • extruding the object along the motion
  • ray cast to the new position
  • swept collision test (convex cast, linear cast)
  • continuous collision detection, including rotational motion

Please read the link for more detail. It is not a trivial issue.
One important thing to ask before try anything: do you really need high speed object?
It is not free (cost more CPU).

Here is another useful link (less useful though) : https://gamedev.stackexchange.com/questions/11961/how-can-i-enable-ccd-in-bullet-physics