Help with 2D blueprint scripting? (slashing)

Hi! Thanks for your help, I really appreciate it.

Anyways, I’m trying to have it so that my character slashes when a certain key is pressed. So far, it basically works with the exception that it keeps looping. I got the idea of checking what frame the animation is on (I’m using Paper2D), and if it is on the last (5th) frame of the animation, then for it to make a boolean variable false which is always checked when the character is about to slash. Unfortunately, I didn’t find such feature or variable included in Blueprint. Does it exist? If not, what would be a good alternative to this?

Edit: I forgot to add, I want the whole slashing mechanic to come to a halt after the last frame or the end of the animation is reached. Thanks!

You got me confused!

Just set the slashing animation as not looping by dragging a wire from that particular animation and typing ‘looping’ in the box and then right click on it (in the components tab) and choose on end animation. Then you can do whatever you want since you will have the exact moment that the slash animation finishes playing.

Cheers.

Hahahaha my bad XD Does this work with Paper2D though? All I’m doing is “Set Flipbook”, I don’t see anything for looping within there. Thanks for the reply!

Ah, I found it. It somehow works, but not completely. The reason why is because, firstly, if you leave the key pressed it will just stay paused at the last animation, and secondarily, because if I leave the key pressed all the slashing logic (damage, impulse, etc.) is still being applied. I want the whole thing to just stop as soon as the animation’s done playing.

Thanks!

I’m on my phone right now, but I’ll check it out when I get home, thanks. But I remember nothing like this in the sidescroller template…

If you take a look at pretty much any template’s jump function, you can see that it does the same thing you want to achieve, play whole animation without loop, not being able to restart the animation while it’s still being played, etc. Just look at the jump functions ^^

Oh boy Oh boy!
You will drive me crazy! :stuck_out_tongue:

Do you have set up the ‘slashing’ key as every frame? If yes that is your problem. It should only fire once. So choose a key and activate it only with “on pressed” That should make it fire once.

Now lets say you want him to go to the idle animation when he finishes the slash animation.

On “s” pressed set animation ‘slash’—set no looping---- do whatever you want to do.

On animation slash end------- set animation looping — set animation"walk"— play animation from start.

Done!

Well, I’m using input (project settings) for my slash key, and the thing works when you use the “on slashing” node. Maybe that is what you’re talking about? I’ll verify it when I get home. Aaaah, I get an idea of what you mean. I’ll try that out one I get home. Is there any way for it to only detect input once? Like if you press and hold the key, it still only detects it once. I think this is what you were referring to :stuck_out_tongue:

The template doesn’t matter, just take a look at the SideScroller 3D, and use the same method with the nodes for the Paper2D, you’ll have to work a little bit with it, to apply the same to the 2D character, but it can be done, and it’s surely working :slight_smile:

All buttons (joypad or keyboard+ shoulder buttons) detect input only once when you press them and only once when you release them. Axis inputs detect every frame.

Alright, that means that I’m doing it correctly then :stuck_out_tongue: I’ll see if I can do what you said when I’m home, ty

But don’t 3D animations have many more different nodes that paper2D doesn’t have?

Alright, I pretty much solved it! What I did was I got the number of frames in the animation, and divided it by the framerate, and that value went through a delay that nulled the effects. Thanks!