Topic was automatically imported from the old Question2Answer platform.
Asked By
Rabbitnap
I want to animate my Enemy with the Animation Player. When Moving left i want the animation player to play the Run Left animation. How can i get the movement direction?
If you are using a RigidBody (as i understood from your question) linear_velocity should be defined. Is the script of the rigid body where you are using that script?
p7f | 2020-07-30 13:30
my mistake, it’s a kinematic body 2d. I mixed it up.
Rabbitnap | 2020-07-30 13:32
Ah, ok,
So from your code, i assume Runner_player is your animation player (you probably assigned something like var Runner_player = $AnimationPlayer or similar?), and velocity is a variable you defined to hold the velocity of the body. I dont see why your code wouldnt work… would you share your full script? remember to use the code sample button for it.
p7f | 2020-07-30 13:38
i found the offender (i don’t know how to say that in english, sorry)
i forget to remove:
sprite.flip_h = velocity.x < 0
thanks for your help, know it’s working just fine. ^^
Rabbitnap | 2020-07-30 13:49
glado to help. You may add your own answer and select it so others can see its solved!