Skip to content
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

Collision detection betwen KinematicBody2D and StaticBody2D and KinematicBody2D unreliable #2097

Closed
gber opened this issue Jun 15, 2015 · 5 comments

Comments

@gber
Copy link

gber commented Jun 15, 2015

Collision detection between a KinematicBody2D and StaticBody2D or KinematicBody2D is unreliable, that is a KinematicBody2D sometimes enters and gets stuck in another KinematicBody2D or it passes through a StaticBody2D. This happens with Godot 1.1. I've created a minimal example at http://code.guido-berhoerster.org/tmp/BugReproducer.tar.gz to reproduce the problem which bounces a KinematicBody2D ball around a playing field delimited by StaticBody2D walls with a randomly moving KinematicBody2D paddle, it just needs to run a couple of minutes and will pause automatically once the ball either moves inside the paddle or passes through a wall.

@mrezai
Copy link
Contributor

mrezai commented Jun 16, 2015

I think this isn't a bug and this behavior is related to Continuous Collision Detection (CCD) concept that implemented for RigidBody2D in godot but not for KinematicBody2D and that cause objects with high speed pass through each others. You need clamp speed to prevent this.
Related links:
http://www.godotengine.org/forum/viewtopic.php?f=12&t=606
Same behavior in other physics engine:
http://stackoverflow.com/questions/8307837/fast-moving-bodies-miss-the-collision-sometimes-in-box2d-andengine

@gber
Copy link
Author

gber commented Jun 16, 2015

I see, thanks for the explanation. However, the velocity of the ball is already clamped and I've artificially inflated it for the above demo because it reproduces the tunnelling effect more often. In my Arkanoid clone the maximum velocity is only a third of that and the tunnelling effect still happens but less frequently. I can't lower it further because then it's no longer fun to play. What are the options then? Should I rather use a RigidBody2D for the ball and turn off friction and gravity?

@gber
Copy link
Author

gber commented Jun 16, 2015

Hm, the forum link you gave me actually suggests that a KinematicBody2D has more precise collision detection than a RigidBody2D, not the other way around?

@akien-mga
Copy link
Member

Sorry about the delay. Is this still reproducible in the current master branch? The example project is no longer available for download.

@gber
Copy link
Author

gber commented Jun 21, 2019

I no longer have the the code to reproduce so this should be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants