- Home /
Bullets going too fast and passing through colliders
My bullets are set to go pretty fast and because of this, they don't always hit the colliders on the enemy. The giant cube wall behind is very thick so the bullet usually ends up hitting that. How can I get it to register the collider and not pass through it because of the high speeds? I set its rigidbody to extrapolate and I don't really notice a difference.
You could either make the collider bigger, the bullet slower, lower the FixedUpdate() timestep speed, or detect the hit with a Raycast rather than the bullet itself.
Changing Collision Detection of RigidBody from Discrete to Continuous solved my exact same problem!
Answer by Doneyes · Sep 08, 2013 at 04:21 AM
I ended up making the bullet longer in the direction it was traveling and now it works like a charm. Thanks
Also, make sure you are editing the position of the bullet through the rigidbody and not the transform component. Editing of position through transform seems to cause a lot of problems if you're expecting collisions.
Answer by Tanoshimi2000 · Jan 26, 2016 at 08:13 PM
For anyone looking at this question, I think the established system for handling this problem is to perform your own collision testing by doing a raycast of either where the bullet is to where it's going to be in the next frame, or where the bullet is, to where it was in the previous frame. In either case, if there's an object detected by that raycast, the bullet would (or would have) hit that object.
I prefer the first version, testing where it will go, because that's going to let you know not just what you (are going to) hit, but where you hit it. For example, I have a helicopter made of many smaller parts. Using this method a fast moving projectile will not just hit the helicopter, but hit the 3rd section of the tail rotar. I can then give that piece it's own rigidbody and collider, then add explosive force to it, and make "debris" fall off the helicopter when it's hit.
Just a suggestion for those who come across this question.
There's also changing the Rigibody's Collision Detection from "Discrete" to "Continuous"
Discrete checks if colliders are touching is x frame then yay we collided! If Collider is INSIDE the other collider this is seen as no we didn't collide, thus where this issue arises.
Continous does exactly what you've said with the raycast checking. You just don't have to do the code ;)
Your answer
Follow this Question
Related Questions
Adding force to a bullet as it hits object? 2 Answers
Rigidbody - bullets becomes bullethole image 0 Answers
Excluding some physics collisions 3 Answers
Avoid overlapping of random spawned prefab 3 Answers
Rigidbody behaves differently when I add a collider 5 Answers