-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Continuous CD not working #9071
Comments
I'd just like to add that comments in those related issues suggest it's only "Cast Ray" that's not working but I've tried this with both "Cast Ray" and "Cast Shape" and neither are working. |
Potentially a result of d7d65fa |
First of all thank you for your report and sorry for the delay. We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to. We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us. For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors. Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed. Thanks in advance. Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it. |
The bug still occurs for both |
Can someone retest after d403b40? |
Tested with current master (11d7738)
With Both behaviours can be seen in this test project |
Seemingly still an issue on 3.1? |
Yes, still occurring on the latest master e16fc72 |
Oh thank god this is an issue and not just me doing it wrong. I have a 3-pixel wide (pixel art game, zoomed in) shield and a projectile that flies kinda quickly, and if I position the character's shield juuuuust right, the projectile gets past the shield. I tried both CCD options and neither of them helped. I really suck at physics, so I really hope this gets fixed. |
@mitchcurtis As a workaround for your particular case, you could make the shield's collision shape thicker. It should work well if its collision layers/masks are adjusted not to collide with the player or other parts of the world. |
Another workaround specifically for projectiles that mostly move in a straight line, is to use raycasts, or an elongated collision shape matching the motion of the projectile for 1 frame. It's a bit of code to write but it should work pretty well. (actually maybe doesnt need code at all, just different setup) |
I need this fixed in order to continue working on my game's mechanics, I am not a great programmer, I am (for now) pretty much a web dev(HTML, CSS, JS) and a year of Python. With my skill set, could I fix this bug? If not, can someone else fix it please? |
Someone please, before 3.2 releases, do something. |
@ZingBlue Sorry, 3.2 was too close to release, we couldn't afford doing something that potentially introduces a regression somewhere else. I advise you look at the workaround given above: #9071 (comment) |
@Calinou No problem. I'll look into the workaround mentioned above. |
I had a look and it seems Bullet only supports continuous collision detection for convex collision shapes. Compound collision shapes (btCompound) are not supported. In Godot any collision shape that has a Another issue seems to be if you use collision layers and mask. Bullet's default handling for this seems to require I don't think Bullet's CCD handles cases where two fast moving objects cross paths at all. Kinematic bodies in Godot actually perform a sweep test for each shape, so continuous collision detection seems to work for them, even for compound shapes. However, Bullet's continuous collision detection for rigid bodies never seemed to prevent tunneling. So even if you use one of the currently supported configurations, it only prevents missed collisions by performing a sweep test with a sphere. There seems to be a way you can manual prevent tunnel in Bullet discussed in this post. While not a complete fix, you can get much less tunneling for basic shapes by choosing the CCD sphere sweep radius as the largest sphere that fits entirely inside the shape. Currently, Godot set's this to Larger sweep radiusvoid RigidBodyBullet::set_continuous_collision_detection(bool p_enable) {
if (p_enable) {
btBody->setCcdMotionThreshold(1e-7);
const btCollisionShape* shape = btBody->getCollisionShape();
if (!shape) {
btBody->setCcdSweptSphereRadius(1.0);
return;
}
/// CCD works on an embedded sphere with fixed radius, make sure this
/// radius is embedded inside the convex objects, preferably smaller.
btVector3 aabb_min;
btVector3 aabb_max;
shape->getAabb(btTransform::getIdentity(), aabb_min, aabb_max);
btVector3 bounds = aabb_max - aabb_min;
btScalar min_bound = MIN(bounds.x(), bounds.y());
min_bound = MIN(min_bound, bounds.z());
btBody->setCcdSweptSphereRadius(MAX(0.04, (min_bound / 2.0) - 0.04));
} else {
btBody->setCcdMotionThreshold(0.);
btBody->setCcdSweptSphereRadius(0.);
}
} In summary, it seems Bullet doesn't have great support for CCD internally, so you'll have to do a fair bit of work to get it working correctly in all cases for rigid bodies. |
Thanks for the analysis @e344fde6bf |
@skaiware I haven't looked into ccd yet, but given there are multiple reported issues, it's an area me or other contributors are going to check. And given @e344fde6bf's findings it seems there's some room for improvements. |
Still an issue in Godot 4 pre-alpha. |
CCD is completely broken in Godot 3.4, but seems to be working in Godot 2.1.4. What can we do to help fix it? It's an important feature when dealing with physics. A workaround would be to detect the collision in GDScript using raycast and apply an impulse or change the velocity to simulate the collision, does anyone have more details on the implementation? |
I don't know if it's the proper way to deal with CCD, but HaxeFlixel engine stores previous positions of objects. This allows to detect overlaps not only for objects themselves, but also for the paths they moved along during the frame. |
This comment has been minimized.
This comment has been minimized.
@LowBudgetHomebrew Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
FYI I'm trying to make a little Pinball game with Godot v3.5.stable.official [991bb6a]. I'm new to Godot, but I have a bit of knowledge on physics and physics engine implementations, so I would be pleased to try to help you fixing that, if I can ;) |
Increasing physics FPS in the project settings will probably resolve this in your particular project (try 120, 180 or 240).
Thanks for your interest in contributing 🙂 See Pull request workflow for guidelines. In particular, pull requests should target the GodotPhysics should also be fixed first, as that's what is used in 4.0 and is the only physics engine available for 2D in 3.x too. Bullet could be fixed later, as it's only used for 3D in 3.x (and people can switch to GodotPhysics there too). |
Woohoo, closing a 5 year old issue! |
If this is the "definitive" issue for CCD not working, then maybe it should be reopened - 2D CCD is certainly still broken in Godot 4.0.2. But the simple steps described here are really not adequate for testing it thoroughly. |
@djrain There is no definitive issue. Please open a new bug report with a reproduction project for the issues that you encounter. (There are some other reports too, btw). |
Continuous CD still bugged. Object stops despite bounce 1: |
@Regrad Please open a bug report with a reproduction project that demonstrates the issue. |
Continuous Collision Detection still not working in Godot v4.3. MY WORK AROUND SOLUTION: Instead of using a RigidBody2D, use a CharacterBody2D! CharacterBody2D seems to have CCD on by default. |
See above, please open a new report |
Operating system or device - Godot version:
2.1.3 Stable (64-bit)
Issue description:
The Rigidbody2D node does not appear to have correctly functioning Continuous Collision Detection (even thought the option is present). "Tunneling" occurs with both "Cast Ray" and "Cast Shape" options.
Steps to reproduce:
I have tried both options (Cast Ray and Cast Shape) and neither of them seem to work. Looking back on previous issues posted here (and elsewhere), it appears Continuous CD was broken since version 2 of Godot was released and never got fixed. Is there any chance this can be corrected soon? It impacts a lot of my testing currently.
The text was updated successfully, but these errors were encountered: