• 2D
  • Problems with tile flicker and player state changing when it shouldn't be.

Hi, new to Godot and working on a first project after taking a tutorial and I've run into two issues I can't sort out so far. For anyone who wants to look at my code/project, it is in this github repo: https://github.com/BPrinjinski/GodotProto

1.) I am seeing, while running, tiles in my room randomly flicker out and back in very quickly. I am not sure what is causing this and don't have any leads, really. Nothing appears to trigger it, and it happens randomly while the game is running.

2.) I have implemented states for my player such as IDLE, MOVE, JUMP, and FALL. I have animations in a state machine for these states, and they were working as intended until I added the FALL state. When on the ground and supposed to be IDLE or MOVE, the animation briefly flashes to the FALL animation and back again. To determine these states, I am looking at is_on_floor(), and if that returns false and the player has a y velocity > 0, I take it to be falling. I am assuming, then, that something is causing is_on_floor() to come back false even when it's true and for some reason there is a positive y velocity for an idling sprite(possibly from gravity?)

Any help is appreciated, thanks!

I am seeing, while running, tiles in my room randomly flicker out and back in very quickly. I am not sure what is causing this and don't have any leads, really. Nothing appears to trigger it, and it happens randomly while the game is running.

This is a known bug, which will be fixed in Godot 4.0. As a workaround, you can enable Use Nvidia Rect Flicker Workaround in the Project Settings (at the cost of performance).

Thanks for your help, that solved the flicker issue!

As for #2, when debugging, it seems, for some reason, move_and_slide is not detecting the collision with the floor in every other frame. So, I'll hit the ground and that will be detected properly, but then I'll call move_and_slide the next frame with a y-velocity of 5.33(my gravity value), and the player won't be moved down, but move_and_slide returns a vector of (0, 5.33). The following frame, when the y-velocity is 10.66, the collision is detected properly and I get back a (0,0) vector. Very strange, and I'm not sure what's causing this. Is there some sort of collision threshold I need to set somewhere?

I found a workaround by using test_move() to check for being on ground instead of is_on_floor(). It's still weird to me that move_and_slide will return the incorrect vector, even when it properly detects and handles a collision(ie. the player never sinks into the ground). Very strange, and I'd like to hear any explanation for this for future reference, but I'm glad I am able to get everything working again.