Transitioning between melee aninations

Somosky

Member
Hi I'm attempting to create my own Sword State Machine and am running into an issue where I can't get the attacks to transition from attack 1 to attack 2 to attack 3.

I have the animations on a full body layer and if I hit "Fire 1" it will play animation 1 and then if I wait until that animation completes and then hit "Fire1" again it will play animation 2 and then do the same thing again animation 3 will play.

However if I try to transistion between 1 and 2 or 2 and 3 or 3 and 1 the animator never transitions between those states and a lot of the time it locks up the animator.

So on my weapon I have 3 audio states. States 2 3 and 4.

I have the Execute Events set up correctly on my aninations and on the weapon I have tried both the use animation events and tried reseting the events using timed events through the weapon.

My transistions between melee 1 to and 3 only are looking for SubState0 audio state 2 3 or 4 depending on the animation that should be played and my use time is currently set at .5f. It was first set at .1f however that would lock up the animator as well.

I've looked at the demo animation controller and it appears I've set mine up correctly.

I'm sort of out of ideas to try. So long story short I can't get my melee aninations to trigger between each other. Just have to wait for it to finish to then trigger the next animation or it locks up the animator.
 
These types of issues are always tough to debug as it requires stepping through the animator in order to determine what the parameters are versus what you expect them to be. The first question to ask your self is when the animator gets stuck are the parameters correct? If they are correct then it's a transition issue. If they are not correct then it likely relates to an event not being sent. Switching out the animator controller with the demo scene animator controller is also a good place to start to see if that works (make sure you are using the latest as Sarah changed the animator a bit to prevent the melee weapons from getting stuck).
 
So after playing around with it some more I've made some progress.

I'd like some clarification on a few things though.

On my weapon I have use Combo enabled and it says is the debug for this variable that it allows the 0 item SubState0 to be changed between item use and item use complete. So changing from 2 to 3 and 3 to 4 and 4 to 2. However the SubState0 won't change for me until the animation event use item complete is called. So I think that's where my issue is.

My temporary work around is on my exit state for each attack animation under settings is to allow transistions to next state. This is not how the demo is set up though so I know it's still not set up right.

Could I make a 1 or 2 minute video to show you what everything is looking like? I've read a bunch of documentation and videos and I'm out of ideas.
 
Unfortunately I'm still getting the Unity issue with the animator inspector not working so I can't take a look at the animator settings specifically, but feel free to share screenshots of how you've set up your animator and the item itself and we can check if there's anything you've missed.
 
Hi Peeps,

I've been revamping our UCC animation controller, rebuilding from scratch, I am stuck with testing 3 attack animations with a sword.
I have configured all transitions-animation events-blend trees exactly like the demo animcontroller setup.
My character performs all 3 animations perfectly when clicking the fire button once, waiting for the animation to complete, then click fire again to perform the next attack animation.
If I spam the fire button my character always locks during attack animation 3.
Turning off Allow Attack Combos checkbox stops the animation lock.
I have 3 animator audio states setup.

What would be causing my lock when using "Allow Attack Combos"?

Would it have anything to do with my "OnAnimatorItemUseComplete" setting? (Screenshot attached)

@Somosky did you have any success with your original issue?

Cheers,
 

Attachments

  • Cutlass_ItemMelee_Weapon (Script).jpg
    Cutlass_ItemMelee_Weapon (Script).jpg
    118.8 KB · Views: 15
  • Animation Attack 3 Mecanim Setup.png
    Animation Attack 3 Mecanim Setup.png
    138.8 KB · Views: 13
  • 3rd Animation Event settings.png
    3rd Animation Event settings.png
    51.2 KB · Views: 14
Hm I can't see anything wrong with your setup, I'm assuming you've setup the animation events accordingly too? Have you tried using a fixed delay instead of waiting for animation on Use Complete?
 
Yes, both ExecuteEvent OnAnimatorItemUse & OnAnimatorItemUseComplete are setup on the animation.
I have tested with an animation from the demo also -Screenshots attached. will get the lockup when spamming button at "Attack3" in mecanim.
tested today - turning off "wait for animation event" on Use Complete, removed the ExecuteEvent from within the animation, tried different durations with the fixed delay. (Does this duration have to be precise to match another setting in UCC?)

will still get the lockup with "Attack 3"

I feel I am missing something basic here. when I uncheck "Allow attach Combos" everything works - I just don't have attack combo ability. :(

Cheers,

EDIT: wait What the? I performed another test right now and found it is not locking up in 1st person perspective, as soon as I change to 3rd person perspective, it locks instantly.
 

Attachments

  • 3rd Animation Event settings 3.png
    3rd Animation Event settings 3.png
    54.6 KB · Views: 5
  • Cutlass_item_Melee Weapon (Script) 3.png
    Cutlass_item_Melee Weapon (Script) 3.png
    49 KB · Views: 5
  • Animation Attack 3 Mecanim Setup_2.png
    Animation Attack 3 Mecanim Setup_2.png
    386.6 KB · Views: 5
Last edited:
Your item's first/third person perspective item properties might be different, so check those. Also enable logging of animation events on the character's AnimatorMonitor, that way you can check if the animation events that are being fired are as expected or not, e.g. if the third attack event is not firing for some reason. That will help you narrow down the source of the problem.
 
Ok, cheers man will take a closer detailed look into these areas. thanks for you help, will let you know the outcome.
 
OK, all animation events are triggering as expected without issues. Checked first/third pers perspective item properties
I disabled Attack 1&2 from within Cutlass item "Animator Audio State" and turned off "Allow combo" - all tests passed.
turned on attacks 2 & 3 with combo - all tests passed.
turned on attacks 1 & 3 with combo - locks up at Attack1 (also locks in 1st person perspective)
turned on attacks 1 & 2 with combo - all tests passed.
Turn on Attacks 1,2 & 3 with combo - Locks up at Attack 3 (also locks in 1st person perspective)

I noticed no animation is playing within first person on Attack3, I see\hear the third person animation playing, attacks 1&2 animations play without an issue in first-person perspective. I am using a different animation controller for the first-person arms. how do I view LIVE the animations playing from within this anim controller.

I can only see the controller animations on the main UCC character previewing LIVE, when I select the first person arms controller I cannot view any animations running LIVE.
 
The animation previewing seems to work fine for me - I've got the first person arms selected and Preview enabled in the Animation window.
 
Okay, so I have something set up incorrectly in my project if I cannot see the animation preview with the first-person arms selected?
I will dig deeper and see what's happening with my animator preview.
 
Might be a Unity bug depending on what version you've got, but I don't think I've ever had that issue before. Make sure that once you've got the animator selected, you select the animation to preview directly from the Animation tab, at the top-left:

1617872493656.png
 
I can view the animation preview when selecting the animation directly from the animation tab as per your screenshot.
I cannot see it playing within first person perspective whilst I run unity play mode, I see the character play the first 2 animations in first person perspective, but he doesn't play the 3rd animation. I have attempted to try a couple of different animation clips, all animations can be seen when in 3rd person perspective.
 
Did you check with logging on the Animator Monitor component to see if the events & animator parameters are changing to what you expect? From this you can narrow down if the issue is with the animator or the melee item.
 
Andrew,

Can you have a look at both the "Execute OnAnimatorItemUseComplete" within AnimatorMonitor Logs named
attacks 1 & 3 with combo - locks up at Attack1 (also locks in 1st person perspective).txt
Attacks 1,2 & 3 with combo - Locks up at Attack 3 (also locks in 1st person perspective).txt

Can you identify any issues at the end of the logs?
is it locking within one of the "Execute OnAnimatorItemUseComplete"?
Are they firing too late and clashing?

Cheers,
 

Attachments

  • AnimatorMonitor_Logs.zip
    13.7 KB · Views: 0
  • Animator_Setup.png
    Animator_Setup.png
    120 KB · Views: 4
Last edited:
If your animator is getting stuck you should first ensure all of the parameters are what you'd expect them to be. If they aren't then it's likely an event issue. If they are then it's likely a missing transition between the current state and the state that you'd like to transition to.
 
OK,
thank you both Andrew & Justin for all your input in solving the issue,
You mentioned "then it's likely a missing transition between the current state and the state that you'd like to transition to"
the problem was a missing transition from my attack 1 to 3, exactly how it is set up in your demo, I need to pay more attention to the reference charts from your demo.
we now have attack combos running without locking issue.
all tests passed.
Woohoo, back in action.
on to the next challenge.

Cheers.
 

Attachments

  • Incorrect Mecanim Setup.png
    Incorrect Mecanim Setup.png
    138.8 KB · Views: 17
  • Correct mecanim setup.png
    Correct mecanim setup.png
    90 KB · Views: 16
thanks, I had a look at that. All that looks fine now. But I noticed that "Slot0ItemSubstateIndex" is updating much faster than the animations play. So I think the issue is, if I hit attack to fast, I can cycle around to the same animation that is playing and therefor it will not exit.

eg
1. Slot0ItemSubtstateIndex 2 is playing
2. I hit attack, Slot0ItemSubtstateIndex = 3,
3. I hit attack, Slot0ItemSubtstateIndex = 4
4 I hit attack, Slot0ItemSubtstateIndex = 5
5. I hit attack, Slot0ItemSubtstateIndex = 2
6. The first combo animation (which is matched to Slot0ItemSubtstateIndex = 2) ends, but since Slot0ItemSubtstateIndex = 2 at this point, it cannot exit/continue.

I'm probably just missing a checkbox or something...
 
On the Animator Monitor you can log the animation events which may give you a clue as to why the index is changing when you don't expect it to. The index will increase when MeleeWeapon.StartItemUse is called.
 
Top