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

[Bullet] Jittering against two discrete, connected walls #34596

Closed
Tracked by #45022
DenisBelmondo opened this issue Dec 25, 2019 · 10 comments
Closed
Tracked by #45022

[Bullet] Jittering against two discrete, connected walls #34596

DenisBelmondo opened this issue Dec 25, 2019 · 10 comments

Comments

@DenisBelmondo
Copy link

DenisBelmondo commented Dec 25, 2019

Godot version:
3.2 dev

OS/device including version:
Windows 10 64-bit

Issue description:
In Godot 3.2, the physics seems to have changed in some way (at least for KinematicBody) that makes sliding along surfaces a lot more bumpy. This is similar to #32182, but this time it's different between versions and it doesn't just occur in corners or exclusively against trimesh shapes (all of the walls are convex in this example).

Behavior in v3.1.2 (desired):

312

Behavior in v3.2:

32

Steps to reproduce:

Open the minimal reproduction project and run it. You will find that you start the scene staring at the wall. Turn to the right, jump over the step and slide against the wall.

image

Minimal reproduction project:

Note: apologies, but this reproduction project currently contains a prepackaged Qodot. This is because I don't believe I'll be able to set up this type of environment with hand-rolled geometry. I could position three skinny StaticBody's against one another but I don't think that would be a proper environment, I would rather have it tested in something more complex like this.

movement.zip

Additional notes:

I tried playing with the safe margins on both KinematicBody and its CollisionShape but it seemed to have little to no effect at all. Furthermore, the effects are much more exaggerated when using BoxShape instead of a cylinder or capsule. However, all of them seem to exhibit some kind of sudden "snapping" behavior from moving between adjacent floors, not walls. I assume this is related to this exact bug.

@DenisBelmondo
Copy link
Author

DenisBelmondo commented Dec 31, 2019

Newest update (Jan 8): Recompiled after #34921 was merged (after cleaning) just to see if it had any effect. Unfortunately none :(

Previous Update: The jittering in-place doesn't seem to happen anymore, but it still happens when walking over "cracks" and sliding against "cracks" as well.

I've created a minimal reproduction project that uses a GridMap. The walls and floors are all made of 1x1x1 cubes. As the entire world geometry is made of way more discrete shapes, it is much more easy to demonstrate this bug here, as well as highlighting that it occurs on floors as well.

Here is what it looks like using plain move_and_slide():

move_and_slide

The jittering is very extreme when standing on four tiles simultaneously, and less extreme when standing on two tiles.

move_and_slide_with_snap():

move_and_slide_with_snap

It's hard to see in the gif, but while there is no extreme jittering while standing in place, the player seems to treat each "line" between tiles as a small crack in the floor, making traversing along it very bumpy.

Additionally, while not shown in the gif, the jittering still occurs when sliding against walls, specifically at the intersection between two like so:

image

I've tried removing the floor check when applying downward velocity (gravity) and the bug still occurs.

Download this reproduction project:

movement_gridmap.zip

@akien-mga
Copy link
Member

CC @madmiraal

@madmiraal
Copy link
Contributor

madmiraal commented Jan 17, 2020

This problem occurs when a KinematicBody using move_and_collide() continuously collides against more than one surface. The continuous collisions are generated by a form of gravity or when the player is pushing against a wall.

This problem does not occur in 3.0.6.
This problem occurs in Godot Physics since 3.1-stable.
This problem occurs in both Godot Physics and Bullet Physics since 3.2 alpha 1.
This problem first started in Bullet Physics with 6dd65c0 a.k.a. #27415, which fixed Bullet Physics to allow for multiple collisions.

My minimal projects:
v3.0:
Multiple Collisions 3.0.zip
v3.1:
Multiple Collisions 3.1.zip

This looks like a duplicate of #28438, #29392, #32182 and/or #34663. However, the problem is more general than described there or here.

Note: This problem also occurs with move_and_slide() and move_and_slide_with_snap() because they both call move_and_collide().

@Calinou
Copy link
Member

Calinou commented Jan 26, 2020

@aqnuep Since you submitted #27415, do you have any idea what could be causing this? See @madmiraal's comment above.

@akien-mga akien-mga added this to the 4.0 milestone Feb 7, 2020
Poobslag added a commit to Poobslag/turbofat that referenced this issue May 5, 2020
Additional workaround for 34596
(godotengine/godot#34596). If acceleration via
gravity makes our vertical momentum something small and we collide with
two objects, there's a risk we won't collide with the surface we're
sitting on which causes an unpleasant jitter effect.
Poobslag added a commit to Poobslag/turbofat that referenced this issue May 5, 2020
Additional workaround for Godot issue #34596
(godotengine/godot#34596). If acceleration via
gravity makes our vertical momentum something small and we collide with
two objects, there's a risk we won't collide with the surface we're
sitting on which causes an unpleasant jitter effect.
@reduz
Copy link
Member

reduz commented Jul 14, 2020

I tested both samples using both Bullet and GodotPhysics. They work perfect with GodotPhysics.

@reduz
Copy link
Member

reduz commented Jul 14, 2020

There was a bug in GodotPhysics that made it break in some scenes which was introduced recently, should be fixed by
#40377.

I suggest using the same logic in the Bullet physics server to ensure it works there too.

@aqnuep
Copy link
Contributor

aqnuep commented Jul 14, 2020

FWIW, I did not encounter such jittering with either convex shapes or trimeshes though I did not test such a scene entirely built from convex shapes.

The type of jittering does seem to be the result of one of the many margin values used throughout Godot and the individual physics servers. I recall making changes on that front too, but that was specific to ray shapes.

Please note though that the pre-3.2 Bullet kinematic body implementation was quite broken and it may just have worked by chance due to often doing literally 1000x more collision checks than necessary (dropping frame-rate to the single-digits) but, of course, it's possible that the fix for that did not address some margin related issues that exist there. In fact, IIRC there were quite some inconsistencies across the Bullet physics server code on how margins are set up for the various shapes, but didn't want to touch those any more than necessary, so the issue is probably around there.

Poobslag added a commit to Poobslag/turbofat that referenced this issue Jul 18, 2020
Additional workaround for Godot issue #34596
(godotengine/godot#34596). If acceleration via
gravity makes our vertical momentum something small and we collide with
two objects, there's a risk we won't collide with the surface we're
sitting on which causes an unpleasant jitter effect.
@pouleyKetchoupp pouleyKetchoupp changed the title Jittering against two discrete, connected walls [Bullet] Jittering against two discrete, connected walls Jan 7, 2021
@fire
Copy link
Member

fire commented Jul 30, 2021

If Godot 4 has moved bullet externally, this issue should also be closed.

@Calinou
Copy link
Member

Calinou commented Jul 30, 2021

If Godot 4 has moved bullet externally, this issue should also be closed.

Someone's been working on re-adding Bullet to Godot 4.0, but I don't know if it'll be merged: #47508

@akien-mga
Copy link
Member

Fixed by #56801.

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

Successfully merging a pull request may close this issue.

9 participants