0 votes

I have a Sprite node that uses animation strips and an AnimationPlayer node that controls the animations. I have a strip 22 frames long, for the attack animation, and I want my character to be locked into the animation for the first 8 frames of the strip, meaning that no matter how much they press jump or try to move, they will still be attacking these 8 frames. After that, the player should be able to move again. How can I do that?

in Engine by (141 points)

For clarity: an animation strip is a single .png file that contains different frames of the animation. If I had separate .png files, i would have used AnimatedSprite.

1 Answer

0 votes

You'll probably want to use 'actor states'. When the character begins an attack, add the attacking state to the list of active actor states (this can be done a multitude of ways, the simplest probably being a dictionary). When the character hits the frame the attack de-facto ends on, OR is interrupted mid-attack, set the attack state back to off. When checking if the player is able to perform actions like jumping, moving, etc. first check that the current blocking states are not active.

by (166 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.