godotengine / godot

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

When jumping on a horizontal-moving slope, the landing point will be shifted #53435

Open TokageItLab opened 3 years ago

TokageItLab commented 3 years ago

Godot version

4.0.dev

System information

MacOS 11.5

Issue description

This is probably a different problem than #52957, since this problem also occurs with apply_velocity_on_leave == Always.

Regardless of the direction in which the horizontal-moving slope is moving, the CharacterBody slips down the slope. So I'm thinking it's a slide or gravity related bug.

50732:

https://user-images.githubusercontent.com/61938263/136039254-fe94e319-ed52-4ecf-b94c-9feab0a43d97.mov

Static slope:

https://user-images.githubusercontent.com/61938263/136039537-1b6c4235-a300-4d80-80f9-bf3124bc4f63.mov

Moving slope:

https://user-images.githubusercontent.com/61938263/136039850-5a89d886-9d81-42a2-aa5a-1e419fc9dd3f.mov

Steps to reproduce

Jump on a horizontal-moving slope.

Minimal reproduction project

50732 and https://github.com/fabriceci/3d-platform-test-for-godot4

pouleyKetchoupp commented 3 years ago

I have an idea what could be wrong here, but I haven't tested to confirm yet. If it's the case it could be relatively easy to fix.

When the platform velocity is applied on leave (Always mode), during the jump the motion is basically diagonal (upward jump + sideway platform velocity).

So what probably happens is that at the moment you fall back into the platform, this diagonal motion causes sliding along the floor (which is the platform) which leads to the shift you see.

I wonder if we could fix this by simply not slide on any floor (moving or not) when the character has just landed. On top of my head I can't think of a case where sliding would be needed in this situation.