Move_and_slide

I read somewhere that you shouldn’t check is_on_floor() before move_and_slide(). The move_and_slide() function sets the value of this method so it’s important not to check it before, or you’ll be getting the value from the previous frame.

Does that make a difference?

1 Like

I’ve not seen this but if you can remember where in the documentation that you spotted this then i can take a look and confirm.
It probably does not affect your game too much but i imagine in a higher paced first person shooter game it might be a bit more problematic if this is the case.

Thanks for highlighting this

The website where I read the information was: https://kidscancode.org/godot_recipes/4.x/2d/platform_character/index.html

The Godot documentation:

bool is_on_floor ( ) const

Returns true if the body collided with the floor on the last call of move_and_slide. Otherwise, returns false. The up_direction and floor_max_angle are used to determine whether a surface is "floor" or not.
2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms