How do I cancel an animation?
I am making a combo system for my fighting game. I have it figured out on my main character and it works well, but I am having an issue with animating the enemy getting hit. I have created different hit animations and used variables to tell the enemy which animation to play.
The problem is, the enemy is still playing the first hit animation in the combo when the second hit animation starts up, resulting in a blend between the 2 animations. Is there any way to cancel the first animation when the second attack in the chain hits?
I have read that I should set the playhead position to 1 when the second attack lands, but that seems to just make its value 0 or 1 (depending on if the signal is powered on or off) and doesn't let the animation play normally.
Just wanted to give an update on my workaround in case it is helpful to anyone else.
I used a selector to determine which animation would play (because the port stays active even after the signal goes off). I switched my animations to “Sustain” and powered them through the selector. That makes the animations start and stop playing at the right time.
Last (and most important!): I Have a gadget that provides a signal to the selector’s Active Port input to tell it which animation to play. I took that very same gadget and wired directly into each timeline’s Restart inputs. Doing this makes the timeline always play from the beginning. Plus, it has an added bonus of allowing the same animation play twice in a row (if needed). My old method would not allow this.
Thanks Xenareee for the help! You sent me in the right direction.
No problem :)
If you want to suggest a new feature, there's always feedback section on this site. Users can vote on ideas, comment, the same you can do with questions. And Mm checks this section too ^^
Thanks for the help! This at least gives me a few things to try. I had all of animations set to “play once”. In this mode it seems there is no way to stop the animation once it starts... I’ll try working with them in “play while powered” mode and see if I can work something out.
Mm if you are reading this, I suggest adding a “cancel timeline” input to the timeline gadget that only works in “play once” mode. It would make complex animations such as combat a lot easier.
To cancel the animation, you just need to power off the timeline. If I remember correctly, there's a few settings in timeline's properties that set how it works. Set it to mode when it plays only when it's powered up, and stops as soon as it loses power (if it isn't the default mode, haha). For example, this works with custom puppet walking animations, they play only when puppet is walking.
For many combos, you can still use a selector if every combo would be emtered in a completely different way (just powering up a selector if you enter a specific combo, so the 1st animation would be standalone).
Or, if you want to have complete freedom and many overlapping attack patterns, you have to program the animations to never overlap. Nodes wired to timelines' power up first would make it possible to turn animations off and on on will.
Or, you can wire the animations only to a selector, assingn a number to every attack combination, and power up whichever should be playing at the time. Just wire the attack-number-wire to the "current option" slot (from the left!) In the selector. This would work only with 0-9 numbers, however (0=A=1st slot, 1=B=2nd slot, 9=J=10th slot). So if you have more than 10 animations, you need to combine two selectors or do something else. If you have more than 10 attack combinations but, let's say, 8 animations, you'll be fine.
As you see, there's many ways of doing that. Feel free to ask if something is unclear :)
I think that would work if I only had one combo. I was planning on going pretty in depth with it... A lot of mix up in attacks means a lot of different reactions to them.
I still need to know how to cancel a timeline anyway. I was also going to add counter attacks (like in Assassins Creed for example). For those I would need to cancel an enemy attack that gets countered and a different animation.
For both of these features I need to be able to cancel the previous animation.
Animations are in the separate timelines, right?
To prevent two animations overlapping, only one should play at a time. What about wiring them to a selector?
For example, if you have 3 hit animations in a combo, have a 3-slot selector and connect every hit animation to the corresponding slot.
It would even make programming the combo easier - you just need to wire what makes the combo proceed (advancing to the next slot), and what makes it break (turning off the selector completely).
Hopes it helped! If you still need help, feel free to ask, I'm following this post :)