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

RigidBody2D continuous collision detection non-functional under Cast Shape setting #72674

Open
vpellen opened this issue Feb 3, 2023 · 6 comments

Comments

@vpellen
Copy link

vpellen commented Feb 3, 2023

Godot version

v4.0.beta17.official [c400205]

System information

Windows 10

Issue description

I'm hesitant to create this ticket because I was under the impression it was a known issue, but the only reference I could find in the physics tracker (#45334) was marked as resolved, and I couldn't find any recent open issue referencing the problem, so I suspect it might have been checked off incorrectly. Apologies if I'm mistaken and this is a duplicate - I promise I really did perform a rigorous search.

Summary: RigidBody2D CCD is non-functional under the Cast Shape setting. The Cast Ray setting works fine. Hell, CharacterBody2D's move_and_slide works fine. Cast Shape, however, doesn't appear to do anything - recreating a tunneling scenario is trivial. Even scenarios that Cast Ray would catch, Cast Shape does not.

Steps to reproduce

Throw a small fast-moving RigidBody2D at a thin wall and watch it phase right through in confident defiance of its settings.

Here, have a script that makes a RigidBody2D aggressively follow the mouse:

extends RigidBody2D

func _ready():
	continuous_cd = RigidBody2D.CCD_MODE_CAST_SHAPE

func _physics_process(delta):
	linear_velocity = (get_global_mouse_position() - global_position) / delta

Minimal reproduction project

N/A

@naturally-intelligent
Copy link

I've also experienced going from v3 to v4, my rigidbody2D bullets with CastShape are going through walls more.

However CastShape isn't totally non-functional. It's still working better than ContinuousCD set to Disabled

@djrain
Copy link

djrain commented Apr 11, 2023

For me, in Godot 4 both modes are broken. Cast ray is completely unusable, it causes weird collisions and damping effects. Cast shape seems to be better than nothing, but there is still quite a bit of tunneling.

Not that this would fix it, but for your sample code, shouldn't setting the linear velocity be done in _integrate_forces()?

@naturally-intelligent
Copy link

Also a bit of an update: in 4.0 I've been get unreliable behaviour when using CastShape or CastRay in a RigidBody2D with more than one CollisionShape2D. I have to reduce it to one shape, and use CastRay to reduce tunnelling to an acceptable level

@naturally-intelligent
Copy link

Has anyone tried ShapeCast2D to workaround this problem?

#54803

@ChknNugz
Copy link

Has anyone tried ShapeCast2D to workaround this problem?

#54803

I tried using shape cast to make my own physics system and I'm losing sleep just trying to implementing it. Physics and the math behind it hurts my head I'm here looking for solutions

@Crowsinus
Copy link

Has anyone tried ShapeCast2D to workaround this problem?
#54803

I tried using shape cast to make my own physics system and I'm losing sleep just trying to implementing it. Physics and the math behind it hurts my head I'm here looking for solutions

I suffer through the same right now. I have been working on this for a few days now and i just can not get ShapeCast2D to work. My Rigidbodies still escape the boundaries (StaticBody2D) and i have literally no idea what to do about it. Extremely Frustrating issue and one of the few things i like more in Unity.

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

6 participants