Need help with player direction

Problem

So my player only changes direction if it’s damping, otherwise it moonwalks somehow…

More Info

here is me replicating the issue
And here is the script for handling player animations and direction

if anyone can help i’ll be very grateful! :pray:

Godot Version

4.2.1

I think the problem is, that you check in your “#handle sprite direction” part online for direction changes if the sprite is already flipped. remove the flip_h condition in your if statement and try it again

1 Like

well it worked! however when it’s sliding (damping), it only slides in one direction like in the video…

It probably has to do with the: “flip_h = direction”. What values does direction have? flip_h is a “bool” and direction is an “int” → the conversions are most likely not exactly what you want. consider using another if statement to fix that

    elif sign(velocity.x) != sign(direction) && velocity.x != 0 && direction != 0:
        flip_h = direction

the flip_h = direction I’m pretty sure gets evaluated to flip_h = direction != 0 which should always be true, you want it to flip if the direction is < 0 I believe

    elif sign(velocity.x) != sign(direction) && velocity.x != 0 && direction != 0:
        flip_h = direction < 0
1 Like

can’t believe the fix was as easy as adding 2 characters lmao
thx tho

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