Need help fixing player movement

The Problem

I’m currently making a 2D platformer and I added some player movement similar to the Mario bros games and the tutorial I found uses scale.x to handle direction, but my player is rescaled and when I turn left, it shrinks my player. There’s also this bug where my player can’t change direction (visually) unless it’s in damping mode.

If anyone can help, I’ll be more than thankful!

Godot Version

4.2.1

The script I used

Click here to see it.

Something about the way you pasted your code is weird… Can you put it on pastebin pls?

BTW PasteBin has syntax highlighting. just turn it on in the top right and select gdscript in the options

here it is godot 4.2.1 player movement - Pastebin.com

still need help btw

Which tutorial? And why would it use an object’s scale to handle its direction? That makes no sense! Also, the code you shared doesn’t use scale.x anywhere!

But if you actually did use scale than this behavior is to be expected?

So it’s a problem with your AnimatedSprite2D? The code you shared includes a call to animated_sprite.trigger_animation(velocity, direction) which likely causes this behavior. But since you didn’t share that function with us, it’s impossible to help you with this.

2 Likes

i used this tutorial for player movement