Godot Version
Godot 4.4
Question
I keep getting this error, have any idea how to fix it?
“in class body” means the line is not part of any function, you need to indent it.
previous_direction
was never declared, I have no idea what you couldn’ve meant either, try removing that line entirely.
velocity has lowercase .x
, not uppercase .X
you can’t call _gravity
without a parameter, but the current state line 32 would cause an infinite loop as _gravity
calls itself forever and does nothing else. Probably remove that entire function and it’s call on line 16.