Topic was automatically imported from the old Question2Answer platform.
Asked By
gm130993
i’ve started using godot a few days ago and i’m currently trying to get a character to play animations when it moves, however it just sticks with the default animation and ignores the whole script
here is the script i’m using:
onready var anim = $AnimatedSprite
func manage_animations ():
if vel.x > 0 :
play_animation(“MoveRight”)
elif vel.x < 0:
play_animation(“MoveLeft”)
elif vel.y < 0 and facingDir.x == 1:
play_animation(“MoveRight”)
elif vel.y > 0 and facingDir.x == 1:
play_animation(“MoveRight”)
elif facingDir.x == 1:
play_animation(“IdleRight”)
elif facingDir.x == -1 :
play_animation(“IdleLeft”)
elif vel.y < 0 and facingDir.x == -1:
play_animation(“MoveLeft”)
elif vel.y > 0 and facingDir.x == -1:
play_animation(“MoveLeft”)
func play_animation (anim_name):
if anim.animation != anim_name:
anim.play(anim_name)
are those functions working? you fing out by writing print(“it’s working”) under them ie
func manageanimations ():
print("working") #if it doesn't print anything it isn't working
umma | 2022-01-30 03:34
i redid your script, try it now, if it doesn’t work i don’t know the problem. Ensure that it is printing something, also if it shows if the code shows error, make sure to remove any space