• 2D
  • Animations utterly broken

I'm trying to make a 2D Platformer from scratch, I have watched 3 tutorials and learn as much as I can from them, but the animations were still utterly broken. I managed to "fix" things enough so that jump and idle animation seem to work fine until I try walking, then it all breaks completely again Not sure what|how should I sent it here to show my current situation

Here's a link to the project: https://www.dropbox.com/sh/at6yj693f4cpgkn/AADjCJeJ_C7KW6CIfBE3Zczaa?dl=0

I just imported your project in Godot 3.4.2.

If I press the A or D keys, the character moves left and right, and a walking animation plays. If I press W, the character jumps and its sprite changes while it's airborne.

I don't see the problem. Could you provide more details?

There's one unrelated error message about the file icon.png being missing.

Yeah, I finally managed to fix it all with the help of someone from the Godot Discord server yesterday.

With that said, I'm still having another issue now... the "is_on_floor" variable keeps setting itself between true and false rapidly whenever I'm walking, and I can't tell why.

Any help with fixing that is appreciated.

( Feel free to ignore the icon.png missing. I deleted it myself years ago. )

You need gravity for is_on_floor() to work.

With that said, I'm still having another issue now... the "is_on_floor" variable keeps setting itself between true and false rapidly whenever I'm walking, and I can't tell why.

I would recommend using a low-pass filter for is_on_floor(), as it's known to be unreliable. In other words, store the results of is_on_floor() for the last 3 frames, and consider it to be true as soon as at least one of the 3 recent frames had is_on_floor() return true.

See also Shifty's character movement manifesto.

Right, because the collision response in Godot (or any physics engine really) aims to resolve collisions. Meaning if an object is going inside the floor, it will move it up to be laying on the floor. But because of floating-point inaccuracy, it is hard to be exactly on the floor, so there may be times where is_on_floor() is either true or false but should always be true. Honestly, this has not been a problem for me. As I check for velocity.y to be above or below some small value (for example to trigger a fall animation) and this works fine.

@cybereality said: You need gravity for is_on_floor() to work.

Gravity is set.

@Calinou said: I would recommend using a low-pass filter for is_on_floor(), as it's known to be unreliable. In other words, >store the results of is_on_floor() for the last 3 frames, and consider it to be true as soon as at least one of the 3 >recent frames had is_on_floor() return true.

See also Shifty's character movement manifesto.

That's absolutely brilliant, thank you so much. I'll definitely try that. And I'll check the link too. Ty.

@cybereality said: Right, because the collision response in Godot (or any physics engine really) aims to resolve collisions. Meaning if an object is going inside the floor, it will move it up to be laying on the floor. But because of floating-point inaccuracy, it is hard to be exactly on the floor, so there may be times where is_on_floor() is either true or false but should always be true. Honestly, this has not been a problem for me. As I check for velocity.y to be above or below some small value (for example to trigger a fall animation) and this works fine.

I've solved similar issues with, myself. at least for the sheer inconsistency of velocity and conditional detection.

I'm surprised Godot thinks such gigantic precision is needed for games of all things. I might have to create a system to round those numbers off, myself...

Ty all for the help. I'll be back later to relay my results

It's not just Godot. This is common with any physics engine in any game engine (though of course, some engines may handle it differently or provide default logic to solve common problems).