1. Use Animation States. This means that you set a state walking = true or movementState = walking on charx > 0.02 for example and then
if movementState = walking and <if animation xy is not playing> animate ....
yours will restart the animation whenever charx > 0.02 which obviously means that you will never leave the initial frame.
if movementState = walking and <if animation xy is not playing> animate ....
yours will restart the animation whenever charx > 0.02 which obviously means that you will never leave the initial frame.