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] KinematicBody jitters up and down when walking along a flat gridmap. #35780

Closed
Tracked by #45022
evsey9 opened this issue Jan 31, 2020 · 28 comments
Closed
Tracked by #45022

Comments

@evsey9
Copy link

evsey9 commented Jan 31, 2020


Note: This issue has been confirmed several times already. No need to confirm it further.


Godot version:
3.2 stable
OS/device including version:
Windows 10
Issue description:
KinematicBody jitters up and down a lot on edges of tiles of a gridmap.
Steps to reproduce:

  1. Get a kinematicbody that you can control with gravity
  2. Get a gridmap with some tiles
  3. Walk around, you'll notice it pretty quickly

Minimal reproduction project:
Kinematic Character 3D Demo from the templates has this bug easily noticeable.
ViVBBp0UAH
#35713 is possibly related.

@Calinou
Copy link
Member

Calinou commented Jan 31, 2020

I can confirm this on commit 6fcb58f. This also occurs when switching to Godot Physics. In fact, it's even more noticeable with Godot Physics (it'll start happening before you even move the cube, unlike Bullet).

Can you reproduce this on any of the earlier 3.2 alphas, betas and RCs? You can download them here.

@rzuf79
Copy link

rzuf79 commented Jan 31, 2020

It's the same on alpha0.
The issue is there also on 3.1.2 with Godot Physics backend. (Bullet works fine there)

@akien-mga akien-mga added this to the 4.0 milestone Jan 31, 2020
@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jan 31, 2020
@Calinou
Copy link
Member

Calinou commented Jan 31, 2020

I ran a Git bisect but only got a commit that's probably not the right one: a9d4cde

Instead of jittering, the KinematicBody will freeze entirely upon touching the ground and won't move anymore at all (even if you press movement keys).

I had to skip many iterations due to several commits not building due to:

scene/gui/texture_rect.cpp: In member function 'void TextureRect::_notification(int)':
scene/gui/texture_rect.cpp:99:14: error: 'struct Rect2' has no member named 'no_area'
   99 |   if (region.no_area()) {
      |              ^~~~~~~

(I tried cleaning my build files after every build, it still didn't work.)

Bisect log
# bad: [a34b77e271da5f3d550acfac1e5557f2467c6266] Merge pull request #32095 from KoBeWi/silly_user
# good: [320f49f204cfbf9b480fe62aaa7718afb74920a5] Bump version to 3.1-stable \o/
git bisect start 'a34b77e271da5f3d550acfac1e5557f2467c6266' '3.1-stable'
# bad: [92277d3a2837e71556768e6479e0bff6b69e4031] Merge pull request #29866 from akien-mga/nothing-that-surrounds-us-is-object-all-is-subject
git bisect bad 92277d3a2837e71556768e6479e0bff6b69e4031
# bad: [b0931806c2a085e84ecc4d7989436edc83cd70a8] Merge pull request #28611 from YeldhamDev/popupmenu_regressionmania
git bisect bad b0931806c2a085e84ecc4d7989436edc83cd70a8
# good: [3069095e44d129058f0f4b5e48f81cbbe1bbaf04] Merge pull request #28066 from jbuck3/popupmenu-plugin-id-fix
git bisect good 3069095e44d129058f0f4b5e48f81cbbe1bbaf04
# good: [5fe971145c2bdebf2d68ee3cb3aeb126c7f68e46] Merge pull request #28347 from homer666/tilemap-hide-menu
git bisect good 5fe971145c2bdebf2d68ee3cb3aeb126c7f68e46
# good: [9d42565f81dd7700347ee6da1e67caf5c49bf922] Merge pull request #27763 from maksloboda/priority-improvement
git bisect good 9d42565f81dd7700347ee6da1e67caf5c49bf922
# bad: [a7f00f3bacbb41f35b7120db6a911eda7c6feac9] Merge pull request #28530 from akien-mga/scons-prepend-cpppath
git bisect bad a7f00f3bacbb41f35b7120db6a911eda7c6feac9
# bad: [2cc8848c3c3815c6f72ce5f9b75bfab8a1498292] Merge pull request #26224 from hilfazer/autocomplete
git bisect bad 2cc8848c3c3815c6f72ce5f9b75bfab8a1498292
# skip: [d6b20e854cbca83175e83c2f87e11d406f332005] Merge pull request #27294 from lupoDharkael/rect2i
git bisect skip d6b20e854cbca83175e83c2f87e11d406f332005
# skip: [419022ea8909f26ac4353cc816c553ca14e0b925] Merge pull request #26977 from bruvzg/fix_x11_window_pos
git bisect skip 419022ea8909f26ac4353cc816c553ca14e0b925
# good: [9b86233e324ec117bc73e8a5ac001f46f8140011] Document built-in LineEdit keybindings
git bisect good 9b86233e324ec117bc73e8a5ac001f46f8140011
# skip: [0da61614c050c208166f9f860e61b9f4b9e048bb] Merge pull request #27204 from YeldhamDev/popupmenu_checkicon_offset
git bisect skip 0da61614c050c208166f9f860e61b9f4b9e048bb
# good: [9742d0c323a441036ee7753b85737aa8051714b3] Spatial::look_at() now preserves its scale values
git bisect good 9742d0c323a441036ee7753b85737aa8051714b3
# good: [7e0c97e73b223d28204fc67672ebae157af1f96c] Merge pull request #27656 from Calinou/doc-lineedit-keybindings
git bisect good 7e0c97e73b223d28204fc67672ebae157af1f96c
# skip: [4e230d713487ea540ca534b11d0bdf225617a676] Merge pull request #27148 from YeldhamDev/creatediag_force_guides
git bisect skip 4e230d713487ea540ca534b11d0bdf225617a676
# skip: [712b789dc83f1d6e9279aa7c9368e6dc3ee7a21e] Merge pull request #26897 from rodolforg/fix_spatial_look_at_affecting_scale
git bisect skip 712b789dc83f1d6e9279aa7c9368e6dc3ee7a21e
# good: [82fadde680c9377e0a8da023a66c921174c97aff] Use filename for scene root of imported models
git bisect good 82fadde680c9377e0a8da023a66c921174c97aff
# skip: [0327d57cfd64b40878a79e5b83f4848001fecb4a] Merge pull request #27007 from BastiaanOlij/arvr_notifications
git bisect skip 0327d57cfd64b40878a79e5b83f4848001fecb4a
# good: [6ee5f7c8819847615c5e96ed92a2a86737350459] Merge pull request #27453 from KoBeWi/glhf_scene_root
git bisect good 6ee5f7c8819847615c5e96ed92a2a86737350459
# bad: [e949d6c2ae64a0faecd595b7589c1690426f18a7] Fix build error after #27294
git bisect bad e949d6c2ae64a0faecd595b7589c1690426f18a7
# bad: [f40c62fa29e8b08fe69487efa92fd08a3dea742c] Merge pull request #27371 from ShyRed/fixdisabled2dcollisions
git bisect bad f40c62fa29e8b08fe69487efa92fd08a3dea742c
# bad: [a9d4cde0f5abc399332dde0c7415b99a5796eb34] Allow adding disabled shapes
git bisect bad a9d4cde0f5abc399332dde0c7415b99a5796eb34
# first bad commit: [a9d4cde0f5abc399332dde0c7415b99a5796eb34] Allow adding disabled shapes

Edit: Reverting that particular commit doesn't solve the issue; the KinematicBody still jitters around heavily.

@jamie-pate
Copy link
Contributor

jamie-pate commented Jan 31, 2020

Confirmed to still be a problem on bullet engine for me. Seems fine if the floor is exactly level, but I think my gridmap floors might be on a very slight incline. The y component is not removed when I call move_and_slide(velocity, Vector3(0, 1 ,0), true) even if the kinematic body is on the floor. is_on_floor() toggles every frame between true/false as well.

sample with collision debug enabled, looks like the edges of collisionshapes are doing weird things?

https://streamable.com/ixwcr

A workaround seems to be
velocity = move_and_slide_with_snap(velocity, Vector3(0, velocity.y , 0), Vector3(0, 1, 0), true)

(now i get this weirdness: https://streamable.com/mdr3r )

@Two-Tone
Copy link

Two-Tone commented Feb 1, 2020

In the Kinematic Character 3D Demo I only have the jittering when the player cube is between two or more floor cubes. On a flat mesh there is no jitter for me.

What GPU is everyone running on? Win7 with an Nvidia 1080ti here.

@Calinou
Copy link
Member

Calinou commented Feb 1, 2020

@Two-Tone I'm using a GeForce GTX 1080 on Fedora 31.

@Two-Tone
Copy link

Two-Tone commented Feb 1, 2020 via email

@Janders1800
Copy link

Maybe related? #34436

@DenisBelmondo
Copy link

DenisBelmondo commented Feb 2, 2020

This looks a great deal like issue 34596 where user @madmiraal listed a number of duplicate issues which hopefully can lend even further insight. move_and_slide_with_snap() does indeed stop jittering on the floor, but any continuous movement in any direction up against a gap between two walls causes the same kind of jitter.

As stated previously, this happens in GodotPhysics (but not Bullet) since 3.1. The jittering occurs in both physics backends as of 3.2 after 6dd65c0.

I am currently on Win10 with a GTX 1060.

@akien-mga
Copy link
Member

#40377 fixes it for GodotPhysics (but not for Bullet).

@jamie-pate
Copy link
Contributor

Another suggested workaround: change the vector in move_and_slide() or whatever you have from (X, 0, Z) to (X, -0.1, Z).

@pouleyKetchoupp pouleyKetchoupp changed the title KinematicBody jitters up and down when walking along a flat gridmap. [Bullet] KinematicBody jitters up and down when walking along a flat gridmap. Jan 7, 2021
@thar0x29a
Copy link

thar0x29a commented Apr 3, 2021

Another suggested workaround: change the vector in move_and_slide() or whatever you have from (X, 0, Z) to (X, -0.1, Z).

This worked on me. Godot 2.32 - capsule/sphere vs cube collision edges. Im not sure WHY and how. But it solved it. Thanks

@NathanLovato
Copy link
Contributor

NathanLovato commented Sep 16, 2021

I can confirm the issue in Godot 3.3.3, but also 3.4, and it happens not only with Bullet physics but also when setting the physics engine to GodotPhysics. Ping @akien-mga as you said it was fixed for the latter. This may be a regression?

Happens in our latest project. Here's a minimal test demo (you can move forward by pressing A, the bumps should be noticeable):

gridmap-collision-bump-bug.zip

@akien-mga
Copy link
Member

I can confirm the issue in Godot 3.3.3, but also 3.4, and it happens not only with Bullet physics but also when setting the physics engine to GodotPhysics. Ping @akien-mga as you said it was fixed for the latter. This may be a regression?

I tested your project, I can reproduce the issue with Bullet, but not with GodotPhysics. I see no bumps with GodotPhysics in Godot 3.3.3-stable, 3.4-beta1 through 3.4-beta4 and latest 3.x (25bd0c3).

The bumps in Bullet are subtle but noticeable, but in GodotPhysics I really don't see any. To be sure, I only go forward/backward in the initial position and make sure that the intersection between the left or right edge of the floor and the bottom of the window does not move.

It seems like you changed the 2D engine from "DEFAULT" to "GodotPhysics", not the 3D one. Maybe that's the issue?

@NathanLovato
Copy link
Contributor

Ah! I didn't know there were separate settings for 2D and 3D. Indeed it's only bullet physics then!

@cybereality
Copy link
Contributor

I have also encountered this issue. I can confirm that it only happens on Bullet physics and GodotPhysics solves it. I made a test project which shows the issue with using Bullet and GridMap collision, and the effect is quite extreme jitter, very noticeable. Maybe that will help debug the problem.
GridMap.zip
.

@tcoxon
Copy link
Contributor

tcoxon commented Oct 12, 2021

Will there be a fix for Bullet in 3.x?

@Calinou
Copy link
Member

Calinou commented Oct 12, 2021

Will there be a fix for Bullet in 3.x?

It depends on whether a contributor finds a fix for it. I think @pouleyKetchoupp investigated this a while ago, but he didn't find a solution to this bug.

@pouleyKetchoupp
Copy link
Contributor

In case anybody would like to contribute on this topic:

The best way to fix most of these Bullet specific issues with KinematicBody would be to rework the code for body_test_motion in the Bullet physics server to match the logic in Godot Physics closer.
Bullet has a few specific things to handle (for instance all shapes include a collision margin) but it should be possible to get something more similar to Godot Physics than the current code.
If someone is interested, let me know so I can help by giving pointers and answering questions.

@Calinou
Copy link
Member

Calinou commented Jan 31, 2022

As mentioned in Shifty's Godot Character Movement Manifesto, the is_on_floor() part can be worked around by using a filter on the is_on_floor() check:

  • Unstable floor results make my 'is grounded' flag jitter
    • This seems to be down to the collision margin system
    • Use a rolling window (2-3 frames should be sufficient) that folds down to a single bool using OR to de-noise the floor check

In other words, create a function that wraps is_on_floor() and returns true if is_on_floor() returned true at least once in the last 3 physics frames (or 2, but it may not always suffice).

@akien-mga
Copy link
Member

#56801 seems to solve this issue, together with a handful of related Bullet bugs which were all regressions from the same change.

I tested the Kinematic Character 3D demo and confirmed that it's fixed by #56801. Note that the current version of the demo uses 120 FPS for physics to work around the issue - it can now be reverted back to 60 FPS after #56801 and the demo would run fine. (I tested both the current version with 60 FPS and the old version from when this issue was opened, both are fixed).

@NathanLovato's MRP is fixed: #35780 (comment)

@cybereality's MRP is not fixed in my test: #35780 (comment)
So I would suggest opening a dedicated issue for it. FYI #56801 should be in 3.5 RC 2.

@akien-mga akien-mga modified the milestones: 3.x, 3.5 May 19, 2022
@NathanLovato
Copy link
Contributor

That's great news, thanks much for the fix!

@akien-mga
Copy link
Member

Fixed by #56801.

@elvisish
Copy link

Bullet still bumps on gaps in gridmaps in 3.5 RC1, doesn't do it with Godot Physics.

@akien-mga
Copy link
Member

That's normal, #56801 was merged after 3.5 RC 1. It will be in 3.5 RC 2.

@elvisish
Copy link

elvisish commented May 31, 2022

Still having issues in RC2 with this, if the KB is moving slow enough, it'll jitter on the gridmap seams. It does not do this with Godot Physics. It only seems to happen if gravity is being applied to ground, or if the KB is walking into a wall while sliding along it.

@akien-mga
Copy link
Member

I would suggest opening a new issue for cases which are not solved yet.

@elvisish
Copy link

elvisish commented Jun 1, 2022

I would suggest opening a new issue for cases which are not solved yet.

Done: #61616

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.