- Home /
Capsule Collider Going Through Box Collider
Im my game, I have the "main" object with a rigidbody and capsule collider, when force is added, sometimes, this object goes through the box colliders(eqquiped with bouncy physics).
And this can't happen anytime, how can i improve this, so that the object never goes through the box collider, and bounces all the time?
Answer by Lyje · Jun 19, 2014 at 01:44 PM
You might need to set collision type to Continuous or Continuous Dynamic: http://docs.unity3d.com/Manual/class-Rigidbody.html
I used to use Continuous Dynamic until a few days ago, i changed it to Discrete. If continuous dynamic is selected, when my game has too many capsule colliders, they get too slow and stop even without any collision.
With discrete selected I dont have those problems, only when rigidbody gets lots of velocity and goes through the box collider.
Continous Dynamic isn't the solution, I have tried and happened anyway.
Thanks anyway !
Have you tried just Continuous? It might solve both problems. If not, there's a workaround you can do which involves doing a raycast every FixedUpdate to see if an object might have gone through another. You do a raycast from your previous position to your current position; if the raycast hits something, you move the object back to the hit point and let Unity figure out the actual collision properly on the following fixedupdate. There's an implementation of this on the Unify wiki here: http://wiki.unity3d.com/index.php?title=DontGoThroughThings
It might be a little confusing though, and I had to modify it heavily for my own usage.
Your answer
Follow this Question
Related Questions
i wanna prevent my collider from falling down flat when climbing slope 0 Answers
Capsule collider bounces where two ground colliders meet 2 Answers
Set a variable to a collider type. 1 Answer
Colliders not inheriting the Transforms of changed animation states(Run to Crawl) -Unity3D, 0 Answers
How do I know if a cube is lying flat on the ground? (the quickest way) 0 Answers