godotengine / godot

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

Collision jittery with SeparationRayShape2D without "slide_on_slope" #77571

Open shunlog opened 1 year ago

shunlog commented 1 year ago

Godot version

v4.0.3.stable.official [5222a99f5]

System information

Issue description

When using a SeparationRayShape2D in a CollisionShape2D, the collision in the moment of landing is jittery (see in the video on the left). In other words, the character body "falls through" the static body for a frame right upon impact, then goes back up on top of the static body, where it should be. What should happen is what you see on the right in the video, the character not falling through the static body, even when "slide_on_slope" is set to false.

movie.webm

This issue didn't exist in Godot v3.5. I've tried different physics parameters, but the only thing that solved it was setting "slide_on_slope" of SeparationRayShape2D to true.

Steps to reproduce

Create a CharacterBody2D with a CollisionShape2D set to SeparationRayShape2D. Make sure that "slide_on_slope" is set to false. Add the default script to CharacterBody2D to enable movement. Create a static body for the character to jump on. Observe that the collision is jittery right upon impact.

Minimal reproduction project

godot4_RayShape_bug.zip

shunlog commented 1 year ago

Here's a clearer demonstration.

Without "slide_on_slope", collision is jittery:

https://github.com/godotengine/godot/assets/48106195/6f3438a8-4fe1-4209-aaee-48279b59582c

With "slide_on_slope", collision is perfect:

https://github.com/godotengine/godot/assets/48106195/7eb0ab2c-a566-49b1-963e-fcb91901670d