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

is_on_floor() detection is buggy #38566

Closed
vickylance opened this issue May 8, 2020 · 5 comments
Closed

is_on_floor() detection is buggy #38566

vickylance opened this issue May 8, 2020 · 5 comments
Labels

Comments

@vickylance
Copy link

Godot version:
v3.2.1

OS/device including version:
MacBook Pro - Catalina

Issue description:
is_on_floor() is returning true one frame and false another frame
Screenshot 2020-05-08 at 3 49 07 PM

Steps to reproduce:

  1. Add a simple kinematic body and apply gravity only when not on floor this bug happens.

I have attached a below project with minimal reproduction

Minimal reproduction project:
MinimalProject

@Calinou
Copy link
Member

Calinou commented May 8, 2020

Duplicate of #35780 (and possibly others).

@vickylance
Copy link
Author

vickylance commented May 8, 2020

@Calinou But the KinematicBody is not in a GridMap or any edge. Its on a plain flat solid ground.
Also the capsule is not visibly jittering. Only the collision value returned is switching each frame. Also if I apply gravity on every frame instead, then its not happening.

@Calinou
Copy link
Member

Calinou commented May 8, 2020

@vickylance I think it's still the same underlying issue 🙂

We have lots of issues reporting this exact problem. There are probably many duplicates lying around already.

@madmiraal
Copy link
Contributor

@vickylance For is_on_floor() to return true, the previous call to move_and_slide() must result in a collision with the floor. If you update the velocity with the post collision velocity, after colliding with the floor the velocity in the y direction will be 0. However, if you also then choose not to apply gravity, the velocity passed to the next call to move and slide() in the y direction will be 0. Therefore, the next call to move_and_slide() won't result in a collision with the floor, and is_on_floor() correctly returns false.

@jcarlosrc
Copy link

This is not "correct". If the body is already colliding with the floor the physics engine should return true. This is, is_on_floor should return true if the body is already touching the floor even if vel.y is 0.

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

No branches or pull requests

4 participants