Godot: Fast RigidBody always go through walls and Godot Crash because of Collision

Created on 27 Jan 2018  路  23Comments  路  Source: godotengine/godot

Godot version:
Godot 3 RC3

Issue description:
Fast moving Rigidbody3D always go through walls
the collision is not always detected .. even if i make the wall thick and add more invisible walls to it .. still go through them

problem number 2 is : when i added a collision to Rigidbody .. everything works fine
select player mesh and : Create Convex collision sibling .. works fine

but when i close the project and i open it again Godot Crash or Close it self

and the way to reopen the project is to open the scene that contain that Collision in a Text editor and remove the line of Collision from there
and in this case , this is the line you must remove from "Level.tscn" to open the project

[node name="PlayerCollisionShape" type="CollisionShape" parent="Player" index="1"]

Steps to reproduce:
use : apply_impulse with higher value inside rigid body
if you set a lower value it will collide well but not for higher value

and this is the project .. if it didn't open for you .. remove the line from Level.tscn in Text editor

Minimal reproduction project:
FastRigidBody.zip

bug physics

Most helpful comment

i have updated the "CCD doesn't work #2228", let's work together to make it work well.

All 23 comments

This is normal, Did you use Constant Collision Detection on rigid body?

CCD or not, tunneling happens at speeds of ~150+ in the OP example project.
I could not test with Godot physics, throws many errors.

@eon-s See https://github.com/godotengine/godot/issues/9071. As far as I know, this is not fixed in Bullet physics.

That was for 2D, this is 3D, @Calinou

If CCD is on, tunneling should not be happen, with CCD off tunneling is normal. So I've to check why it happens when CCD is on

IIRC ccd is currently broke

I ran into this problem yesterday. The CCD did not work for my fast objects.

I did some testing, and it seems like the collision detection is working if I increase the object size. For a simple RigidBody Sphere I made the following observations:
At a radius of 1.5 and a rigid body speed of 214 it is colliding. If I increase the speed by 1 to 215 it does not work anymore.
At a radius of 1.0 and a rigid body speed of 153 it is colliding. If I increase the speed by 1 to 154 it does not work anymore.
At a radius of 0.5 (so a width of 1 unit) it is really weird: following speeds (for example) work: 61, 62, 70, 71 while others (eg 60, 72) do not work. I wasn't able to find a pattern about when it works and when not.

Another thing that I noticed:
A Sphere with the radius 0.1 and a speed of 30 can pass through too. I think I have a explanation for this one:
In rigid_body_bullet.cpp line 704 the ccd motion threshold is set to 1.
(https://github.com/godotengine/godot/blob/master/modules/bullet/rigid_body_bullet.cpp#L700)
If I understand physics correct this means that ccd will only be used if the body moves more than 1 unit in the frame. At a physics framerate of 60 FPS this means that ccd is only used for linear velocities greater than 60 (as this means 1 unit per physics frame). So ccd is not used for a sphere with radius 0.1 and a speed of 30. At a speed of 30 the sphere moves 0.5 units per physics frame. The sphere only has a radius of 0.1 (so a width of 0.2) and that means that there is a gap of 0.3 units that are not checked each frame. See the image
bug_godot
So I think the motion threshold should be calculated based on the smallest possible line through the object (for a sphere this is the radius*2).
This would enable CCD also for smaller objects at low speeds, and I think that is what most users will expect from a continuous detection: no tunneling, no matter of the size of the object. I guess this is only a solution for my small and slow object and not for the general not working ccd.

I am not an expert at physics simulation, maybe everything above is wrong. I just thought I would drop my thoughts about it here, maybe it's helpful.

If there is anything I can do to help (for example testing) that does not involve coding in C++ then I am happy to help as I would like to use CCD in godot.

Ok please forget what I was saying in the first part of my previous comment:

At a radius of 1.5 and a rigid body speed of 214 it is colliding. If I increase the speed by 1 to 215 it does not work anymore.
At a radius of 1.0 and a rigid body speed of 153 it is colliding. If I increase the speed by 1 to 154 it does not work anymore.

This was false. I was now able to find other values (for example below 214 for the radius of 1.5) that also do not collide, so it seems like there is no pattern when it works and when not.

@paul-dosenbrot CCD is supposed to prevent the tunelling in these cases, it seems it do not work at all, you can try switching to Godot Physics and check if fail in the same velocities (I was unable to make godot physics work).

Other things that can be checked are if PhysicsDirectSpaceState.cast_motion() fails too, I suppose it should fail if it is using the same methods.

Has anyone looked into this?
Continuous Cd still seems to be broken.

Am seeing the same problem (Godot v3.0.6) . Is this bug is in all Godot 3.x versions? And is there any reasonable workaround other than changing to Godot Physics?

@takeontom a workaround can be making your own tunnelling prevention system, but will depend on each case what you can do to make corrections, predictions...

I am experiencing the same, I have a custom build (942855a, built today 2018-11-26).
Using bullet and continuous CD enabled.
If anyone can direct me to the code I am willing to give it a try.

It seems to not penetrate the statics consistently on 3.1 with the OP project, but keep pressing space and after a few tries the rigid go through the solid.

This is not a fix, but is an improvement of the CCD thresholds calculation: #28595

Is necessary to open a issue in the bullet github because the ccd is turned off with any threshold.

i have updated the "CCD doesn't work #2228", let's work together to make it work well.

Here's a simple test project (Godot v3.2 Beta) showing the tunneling that is occurring with RigidBody (regardless of whether CCD is on or off):
ezgif com-video-to-gif (1)

Make sure to enable Debug -> Visible Collision Shapes

Note: This scene is a RigidBody 3D with an Orthogonal Camera to better view the collision tunelling.

rb3dtest.zip

Is the updated merge of bullet inside Godot still planned? Hoping that fixes CCD for 3D

If you refer to https://github.com/bulletphysics/bullet3/issues/2228#issuecomment-492972622, bullet has been updated in June 2019, so it's newer than this comment.

Bullet is implemented for 3D, but, from my understanding, the intent is to stick with Godot's physics for 2D, since it has some custom behaviors (one-way collision, and things like that).

This issue is referring to 3D and Bullet Physics. There is a separate issue for CCD on 2D Rigidbody.

While testing again on 3.2b, I have found that this only happens on rigid mode, CCD seems to be working fine on character mode (at least with the OP example).

Hi every one, is there any update?
I have this issue on rigidbody2d too.

Was this page helpful?
0 / 5 - 0 ratings