In a previous project, I had exactly the same issue. It was impossible to get it working in a reliable way. I don’t know if it is a bug, or if there is a more detailed description in the docs about it.
I had to use a manual solution, using sphere raycasts during the fixed update to get the required result.
I think so, at least, I never got it the work. But to be fair, I never had the time to investigate it really in depth. So maybe it works, but it was on my/our end.
You need to add kinematic rigidbodies set to “Continuous” to any obstacles that you want to interact with the rigidbody set to “Continuous Dynamic”. (Nope, that’s not how it’s described in the docs, but that’s how it actually works…)
Unity’s physics are software-only; there are no PhysX drivers to have problems with. In your sample, add rigidbodies to all the obstacles, mark them as kinematic, and set them to Continuous.
I’ve done exactly that. And it doesn’t work.
The bullet goes through the floor and all other objects.
Not at every position.
Here is the video I’ve recorded:
collision in unity is normally dependent on the size of the collider such as being to small it can go through things sometimes and the speed in which it travels. now if you are planning to do things such as a bullet that has physics and so on that’s not imposible just go ahead and instantiate it a a rigidbody to let it fly and so on and use raycasts on the actual bullet to do the collision instead. or a line cast between the tip of the bullet to the end. raycasting and any form or imaginary ray it’s normally the fastest and duable aproach in collision since it never fails.
That’s not completely correct. The continuous collision feature is exactly made for ultra fast objects.
What you do with your raycast method is to simulate that feature, that already exists.
(Look at the original physx examples, it works! (with small objects, too))
Eric says, it works for him, that’s interesting. If that’s true, it could be a different version of unity and perhaps physX
or a hardware/software bug in any form.
I don’t want to rewrite that feature! It exists in nearly every modern physics engine and I want to use it!
honestly by experience, like i mention continuos collision seems to work slightly but in the end i ended relying on raycast. i can’t say that it’s fully using physx sime some claim that the current unity is using software physx. perhaphs i will attempt the same thing you are doing and see what i can find from this.
After a long time, I’ve found the solution. I’m using Unity 4.3. If you look into the documentation of the enum “CollisionDetectionMode”, this is the text of “CollisionDetectionMode.Continuous”:
Collisions will be detected for any static mesh geometry in the path of this Rigidbody, even if the collision occurs between two FixedUpdate steps. Static mesh geometry is any MeshCollider which does not have a Rigidbody attached. This also prevent Rigidbodies set to ContinuousDynamic mode from passing through this Rigidbody.
So, it only works, if the static objects in my scene have a mesh collider instead of a box collider!
That’s it. Now, it works perfectly!
@Zeminor: As nothing of that is sufficiently documented, we should file a bug report. Would you like to that? If not, I am going to make it.
Edit: After having another look at the documentation, it seems that Unity heavily improved it regarding continuous collision detection. It doesn’t seem to be necessary to report it.