godotengine / godot

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

KinematicBody2D: odd move_and_slide behaviour when exactly on tile edge #44882

Open snoopdouglas opened 3 years ago

snoopdouglas commented 3 years ago

Godot version: 3.2.3-official

OS/device including version: Ubuntu Linux 20.04

Issue description: Possibly related to #33833.

When using KinematicBody2D's move_and_slide or move_and_slide_with_snap to enact gravity, I've noticed that when a body is exactly on the diagonal edge of a tile:

So we essentially end up with a Mario 64 speedrunner's dream:

Screenshot from 2021-01-02 23-31-42

Interestingly, the value of y tends to fluctuate, and sometimes (seemingly non-deterministically) the body unhooks itself and so goes flying downwards.

Steps to reproduce:

Minimal reproduction project: floor-wall-test.zip

madmiraal commented 3 years ago

Related to #43012 and #43014.

snoopdouglas commented 3 years ago

I've reproduced this in 3.2.4-rc1.

Edit: still reproducible in 3.3.4

pouleyKetchoupp commented 3 years ago

Confirmed still present in 3.4 beta 6 and master (6877cccfb19a88211f864dade18eea7b12719c35).

MaxMarauder commented 1 year ago

I can confirm that the issue is still reproducible in v3.5.3.stable.official.

Here's a workaround I used:

    if is_on_wall() && is_equal_approx(position.x, round(position.x)):
        position.x += 0.001