Player isnt moving for some reason

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Erto

Hi. I have just wrote a basic left and right movement and it ist just moving. Everything seems alright to me and I just cant figure out whats wrong. I would appreciate your help!

:bust_in_silhouette: Reply From: jgodfrey

move_and_slide() already calculates frame-based motion internally, so you should not multiply your movement vector by delta as noted in the docs.

While that shouldn’t prevent motion, it’ll definitely slow it way down…

That said, I think the real problem is that this line…

velocity = move_and_slide(...)

… is inadvertently indented, making it part of the preceding else block. You need to unindent that line so it executes in each frame…

Indeed. Your logic only ever call the move_and_slide when the movement is 0. Unindenting it will make it get called each frame

godot_dev_ | 2023-05-17 16:33

Note, answer edited to fix broken docs link…

jgodfrey | 2023-05-17 17:21

Hi! Thank you so much! It was that move_and_slide was inadvertently indented . I can´t belive I missed something so trivial. I read that code over so much and totally forgot to check that. Thank you also for pointing out the delta thing.

Erto | 2023-05-17 19:55