Godot: move_and_slide with low Y linear velocity bounces endlessly

Created on 9 Aug 2018  路  11Comments  路  Source: godotengine/godot

Hi there,

Godot version:
3.1.dev.custom_build.b5a20d2

OS/device including version:
OS: Ubuntu 18.04.1 LTS x86_64
CPU: Intel i5-4210H (4) @ 3.500GHz
GPU: NVIDIA GeForce GTX 970M

Issue description:
For no reason I can come up with (keeping in mind I'm a major newb with Godot), move_and_slide behave weirdly, namely 'bouncing' without stopping when I give it a linear velocity with a low Y component.

Steps to reproduce:
I show you in this gif

Minimal reproduction project:
Project.zip

Thanks for your time :)

bug physics

Most helpful comment

I can't reproduce and I am confident I fixed this, so closing it.

All 11 comments

https://github.com/godotengine/godot-demo-projects/blob/master/2d/kinematic_character/player.gd
http://docs.godotengine.org/en/3.0/classes/class_kinematicbody2d.html#class-kinematicbody2d-is-on-floor

is_on_floor is intended to be used _after_ move_and_slide, because move_and_slide is what updates that status in the first place. Not saying it'll fix your issue, but I see that mistake being made constantly and at this point I'd really like to know where people are getting that idea from.

Well that's a good point !
I was following a tut' so I kinda trusted it.
Plus As in the script we check is_on_floorand ui_up in order to set the vertical motion, it kinda make sens, I guess ? Like if at last frame we're on the floor and we press the key, then move up on the current frame.
Anyway, doesn't fix it, still confused but thanks for the input

I'm looking at the code shown in the GIF, and it looks really similar to the code I had when I made #16250. Related or duplicate issue?

The "following a tutorial" part is exactly what interests me! I'd like to know which tutorial it was, to notify the writer and maybe get them to update it. The fewer "noob pitfalls" we have in the community, the better :)

Hey @PetePete1984 , it was a video tutorial from HeartBeast too bad it's hard to edit as it's a vid' :cry:
(still was a good tut' IMHO :p )

@PetePete1984 Thing is, I don't think the tutorial is at fault. His code, as is, shouldn't have is_on_floor flickering like it is, regardless of whether move_and_slide comes before or after the usage. If move_and_slide is the only thing that updates is_on_floor, then I don't think the order of the functions is to blame in any scenario..

I had a similar issue with 3.0.6

Made a small workaround for it, but it might not suite many cases.

I'd like to add what I found - It seems like the collision detection isn't consistent and due to that the gap between the character and the colliding body isn't constant. Because of this there's also a problem where sometimes a visible gap is left between the character and the colliding body, which makes it look like the character is floating in my case. (It's clearly visible, so it's definitely not just the safe margin, which I tried even setting to it's minimum)

still occurring in 3.1a1. If there's no vertical delta since last frame where the body was pushed out of the floor, is_on_floor() will return false and cause the state to flicker true/false every other frame (when a delta towards the floor normal is applied).

Is this still reproducible in the current master branch?

I can't reproduce and I am confident I fixed this, so closing it.

Was this page helpful?
0 / 5 - 0 ratings