Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Zuckey |
I’m trying to make a running animation to play at 8 directions but it seems to restart the animation at each direction change, I want it to continue from where it left. I’m using spritesheets and AnimationPlayer for animation. How can I manage this?
All your animations have the same ammount of trames? could you share your current code where you manage animation changes?
p7f | 2020-09-28 20:43
func animation_loops():
if direction <= 15 and direction >= -15:
animation_direction = "E"
right_arm.set_z_index(1)
left_arm.set_z_index(-1)
weapon1h.set_z_index(-1)
elif direction <= 60 and direction >= 15:
animation_direction = "SE"
right_arm.set_z_index(1)
left_arm.set_z_index(-1)
weapon1h.set_z_index(-1)
elif direction <= 120 and direction >= 60:
animation_direction = "S"
right_arm.set_z_index(0)
left_arm.set_z_index(0)
weapon1h.set_z_index(-1)
elif direction <= 165 and direction >= 120:
animation_direction = "SW"
right_arm.set_z_index(-1)
left_arm.set_z_index(0)
weapon1h.set_z_index(-1)
elif direction <= -15 and direction >= -60:
animation_direction = "NE"
right_arm.set_z_index(1)
left_arm.set_z_index(-1)
weapon1h.set_z_index(-1)
elif direction <= -60 and direction >= -120:
animation_direction = "N"
right_arm.set_z_index(0)
left_arm.set_z_index(0)
weapon1h.set_z_index(-1)
elif direction <= -120 and direction >= -165:
animation_direction = "NW"
right_arm.set_z_index(-1)
left_arm.set_z_index(0)
weapon1h.set_z_index(-1)
elif direction <= -165 or direction >= 165:
animation_direction = "W"
right_arm.set_z_index(-1)
left_arm.set_z_index(0)
weapon1h.set_z_index(0)
if idle_state == true:
animation_mode = "Idle"
anim_player.playback_speed = 1
else:
animation_mode = "Run"
anim_player.playback_speed = 2
animation = animation_mode + "_" + animation_direction
anim_player.play(animation)
Currently I have an idle and a running animation my idle is 8 frames long and running is 16 frames long.
Zuckey | 2020-09-28 20:48