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

[3.x] Backport KinematicBody move_and_slide and move_and_collide fixes #50495

Merged
merged 2 commits into from
Jul 19, 2021

Conversation

pouleyKetchoupp
Copy link
Contributor

Backport #49901 and #50063 to 3.x.

These two PRs together make both move_and_collide and move_and_slide more reliable and after running a lot of tests (see original PRs for details) I'm confident they won't cause major regressions.

Co-authored by @fabriceci
Supersedes #49902

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a rebase, otherwise seems good to go.

pouleyKetchoupp and others added 2 commits July 19, 2021 08:09
Make sure the direction of the motion is preserved, unless the depth is
higher than the margin, which means the body needs depenetration in any
direction.

Also changed move_and_slide to avoid sliding on the first motion, in
order to avoid issues with unstable position on ground when jumping.

Co-authored-by: fabriceci <fabricecipolla@gmail.com>
* Safe and unsafe motion are calculated by dichotomy with a limited
number of steps. It's good for performance, but on long motions that
either collide near the beginning or near the end, the result can be
very imprecise.
* Now a factor 0.25 or 0.75 is used to converge faster when this case
happens, which allows longer motions to get more accurate collision
detection.
* Makes snap collision more precise, and helps with cases where diagonal collision on the border of a platform can lead to the character being stuck.

Additional improvements to move_and_slide:
* Handle slide canceling in move_and_collide with 0 velocity instead of
not applying it.
* Better handling of snap with custom logic to cancel sliding.
* Remove small jittering when using stop on slope, by canceling the
motion completely when the resulting motion is less than margin instead
of always projecting to the up direction (in both body motion and snap).

Co-authored-by: fabriceci <fabricecipolla@gmail.com>
@pouleyKetchoupp
Copy link
Contributor Author

@akien-mga Thanks, it's rebased.

@akien-mga akien-mga merged commit 526447b into godotengine:3.x Jul 19, 2021
@akien-mga
Copy link
Member

Thanks!

@pouleyKetchoupp pouleyKetchoupp deleted the move-and-slide-fixes-3.x branch July 19, 2021 22:15
@elvisish
Copy link

Would it be possible to consider this for an update to move_and_slide? godotengine/godot-proposals#2751

@crapaam
Copy link

crapaam commented Aug 29, 2021

Hi. I have a little platformer game. the player moves with move_and_slide_with_snap. it works fine with godot 3.3.3 and 3.3.2, but got problems with 3.4 b4. The problem is when the player is over a platform that moves from side to side, the platform moves, but the player do not. The platform is made with a tileset. The static body is made with the tileset to and moved with an animation player. Thanks

@pouleyKetchoupp
Copy link
Contributor Author

@crapaam Hi! Please open an issue with a test project so someone can investigate the regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants