Hey, I’m trying to create a melee combo system, and I want a button press to enable a variable for a period of time based on the length of an animation. The length of the animation can changed based on attack speed so i need to set it as a variable that the delay uses.
Your timeline for the animation should have start and finish exec pins. You should be able to:
Press Button -> Enable Variable -> (Start) Animation Node (Finish) -> Disable Variable
Alternately, if you’re determined to use a variable input to the delay node, you could just multiply your delay node variable by the same number you multiply your animation speed by…
I don’t see a node to start animations in the MyCharacter blueprint, and i can’t set button presses in the animation blueprint.
Is there any chance you could show me an example of a basic melee system that i could work from?
Looking at the First Person character default, it looks like the node you might be after is ‘Montage Play’, With the Target being the’ Get Anim Instance’ of the ‘Mesh’ you want to animate.
At least that is how the firing animation has been done there.
But what if you play the animation from a machine state and you want to get the animation time of that animation that is currently playing in particular?
Plus, it seems that you can’t use Animation Montages from within state machines for some reason.
Character supports Play Anim Montage, Stop Anim Montage directly without getting GetAnimInstance(), but also if you do GetAnimInstance, you can access function PlaySlotAnimation directly and play any sequence.
>>But what if you play the animation from a machine state and you want to get the animation time of that animation that is currently playing in particular?
The state machine is handled separately. They’re state machine, so the correct way to do this seems to be “Activate the state”, not play the animation in the state.
So if you have a variable A that activates state Fight, then you just have to set that variable correctly.
>> I’m trying to create a melee combo system, and I want a button press to enable a variable for a period of time based on the length of an animation. The length of the animation can changed based on attack speed so i need to set it as a variable that the delay uses.
In this case I think using montage is the best way because montage provides very detail control of speed, section, segment control. You can have montage with that certain section, and you can control playrate or looping or jumping to another state.
Please check ContentExample/Animation map’s montage example. That example has punch animation that only punches during the button is hold. However you’ll notice it won’t pop out after that since all it does is to redirect to different ending depending on where you were in the section.
Hope that help
I’ve figured out how to do everything i want with state machines, now just waiting for anim sequences to support root motion.
I would love to hear what you’ve learned:)
In transition rules there is a timeRemaining and timeRemaining (ratio) node. If you flick the variable on and off with a button press, it will trigger the anmation and you can prevent the animation from stopping until it either is near ending, or you extend the combo. I used a tiemRemaining (Ratio) of 0.4 for the aminations i had for going into a new attack and 0.05 for going to idle.
Unfortunately, if you have an animSequence variable determining which animation is played, it will actually use the length of the initial animation chosen and not the updated one when the variable changes.
This causes some problems with my current system, but hopefully there is a way around it.