godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.78k stars 21.13k forks source link

Cast Ray CCD drastically affects bounce (vs Cast Shape or disabled CCD) #76621

Open Exoow opened 1 year ago

Exoow commented 1 year ago

Godot version

4.0.2

System information

Windows 10 - Godot compatible mode

Issue description

I tuned the ball scene (RigidBody2D) and its parameters to have the exact bounce I like.

After experiencing issues with the ball moving through StaticBody2D object, I updated the CCD to Cast Shape. This improved the behavior but didn't fix it entirely (another bug?). However the bouncing behavior remained unaffected.

Then I updated the CCD to Cast Ray. This improved the behavior and seemed to fix the issue. However the bouncing behavior started acting unexpected. As if dampening suddenly is very high, but then at the end the ball keeps the same bounce forever (no damp).

Steps to reproduce

Open the attached project and see the difference in bounce between the left ball (Cast Ray) and the others (Cast Shape or disabled)

Minimal reproduction project

RaycastBounce.zip

rburing commented 1 year ago

The raycast CCD implementation modifies the velocity so that it just hits the target instead of going through the target (or deep into the target). This explains the behavior, but I don't know what should be done about it.

Exoow commented 1 year ago

The raycast CCD implementation modifies the velocity so that it just hits the target instead of going through the target (or deep into the target). This explains the behavior, but I don't know what should be done about it.

Thanks for the info. It's a bit disappointing to see this basic physics feature not properly available in Godot.

Crowsinus commented 7 months ago

Can confirm this issue.

werner291 commented 2 months ago

Is this perchance related to the constant_linear_velocity property?

I noticed some of my issues seem to have vanished after unsetting that (to null, I'm guessing? A 0 vector doesn't seem to work) and applying a velocity through a script to any colliding objects. (One of which was a small ball with raycast CCD enabled)