Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | luci3000 |
My player node’s structure is:
KinematicBody2D > (AnimatedSprite, CollisionShape2D, Camera2D)
This is my movement function:
func _physics_process(delta):
motion.y += GRAVITY
if motion.y > MAXFALLSPEED:
motion.y = MAXFALLSPEED
motion.x = clamp(motion.x, -MAXSPEED, MAXSPEED)
if Input.is_action_pressed("right"):
animated_sprite.animation = "walk-left"
animated_sprite.flip_h = true
motion.x += ACCEL
elif Input.is_action_pressed("left"):
animated_sprite.animation = "walk-left"
animated_sprite.flip_h = false
motion.x -= ACCEL
else:
motion.x = lerp(motion.x, 0, 0.2)
animated_sprite.animation = "standing"
if is_on_floor():
if Input.is_action_just_pressed("jump"):
motion.y = -JUMPFORCE
motion = move_and_slide(motion, UP)
It was working perfectly when I was using a Sprite node as a placeholder. Then as soon as I changed to an AnimatedSprite, even before putting the animation changes on code, it stopped working. It is currently triggering the animation but moving about two pixels and stopping. I’m able to move vertically, though. How is the AnimatedSprite interfering with the movement and why?
Thanks in advance for any help.
I just realized the indentation is wrong here, but on the Godot editor it’s right, just this textbox messing with the formatting.
luci3000 | 2023-01-01 20:51