What type of melee combat animation do action JRPG use and how can I make them work with TPC

Hi,

I am starting a new project and I would like to have an action combat system similar to action JRPGs. This is my first project where I will be using 3D animations, so I am not very familiar with root motion, IK, animation masking and humanoid animation in general. The gifs below show the type of simple attack combo I would like to start with.
NierAttack.gif
NiNoKuniIIAttack.gif
And this is what I got by using the default sword animation from TPC
MygameAttack.gif

So I have a few questions which I hope some of you might help me answer
  1. Do these animation combo use root motion? I think they do, but when attacking enemies these animations will sometimes move the character further to reach an enemy or on the contrary make the character move less to chain up attacks when enemies are close. Is this achieved using animation blending or is the character motion regulated by a blend of code and root motion.
  2. In Nier:Automata and Ni No Kuni II the characters do full 360 turns in their combos. I would like to do the same (it gives a more fantasy like combat style), Is there any issues that can be caused by doing this, for example that the forwrd of the characters gets slightly offset by each combo? If that is the case what could I do to remedy these issues?
  3. How can I replace animations for specific weapons in the animator controller? The documentation is not clear about how it works
  4. Does TPC use full body animation when attacking or is it separated in upper body attack and lower body walk?
  5. How can I chain attack in a combo sequence? The sequence parameter in the weapon item starts attacking is not reset when the first animation has stopped. I read somewhere that there would be a way to do this in version 2.1 of UCC. Is that correct?
  6. Finally, at the end of a combo, there is usually a bigger attack that sends enemies flying. How can I make the same weapon have different effects (damage, knockback, draw-in, etc ...) on each strike.
  7. Extra question: I haven't found a way to get a knockback animation to play when attacking an enemy. How would I do that?
The documentation of UCC on the animator controller and how it works is lacking in my opinion. It would be great to have more information on how the animator controller could be modified with new animation or even generic models. If there were videos that showed an example of modifying animation that would be even better.

I will probably continue posting questions on this thread as I continue on my project because I would like to do things like mid-air combos (with the character & enemy floating while you attack), dodging, blocking/pary, swapping weapons in the middle of a combo (eg. strike 1 2 and 3 with weapon A followed by to strike 2 of weapon B), etc...

Thank you for your time
 
Last edited:

Justin

Administrator
Staff member
Answering what I can -

Is there any issues that can be caused by doing this, for example that the forwrd of the characters gets slightly offset by each combo?
That's no problem.

How can I replace animations for specific weapons in the animator controller? The documentation is not clear about how it works
Unity has a lot of resources on how the animator works so we have a few pages which give the overall structure of the animator controller but since it's all stock-unity we instead point to those resources for the replace animations page. Furthermore, the animator controller structure doesn't matter to the character controller so if you wanted to start from scratch with your own animator (making sure you add the same parameters) you could, and is actually recommended since the animator controller that we designed works well for the demo scene but it doesn't necessarily mean that it would work the best for your game.

To answer your question though, you can look at the transitions to a specific state to see if that particular item id transitions to it. If it does then that state is used by the item.
Does TPC use full body animation when attacking or is it separated in upper body attack and lower body walk?
The full body. Take a look at this page for an explanation for each layer.

I read somewhere that there would be a way to do this in version 2.1 of UCC. Is that correct?
That's correct.

Finally, at the end of a combo, there is usually a bigger attack that sends enemies flying. How can I make the same weapon have different effects (damage, knockback, draw-in, etc ...) on each strike.
In version 2.1 you can set a state for each AnimatorAudioState element. This will allow you to have different properties for each attack.

I haven't found a way to get a knockback animation to play when attacking an enemy. How would I do that?
We'll have an example in 2.1, but right now you can subscribe to the OnObjectImpact event and play a knockback animation based on that impact.
 
Hi @Justin , I am having a few issues implementing my attack combo I was wondering if you could point me in the right direction.

I have a sword attack animation with 5 strikes that my brother kindly made for me so I could test the combos.

SwordAttackCombo.gif

In Unity I split the animation in 5 "strikes" and "waits" (waits are the animations that can be interrupted by the player) and add the events for the "strike" animation with function "ExecuteEvent" and strings "OnAnimatorItemUse"/"OnAnimatorItemUseComplete". To be clear, the time between these two events is the time where my character can deal damage correct?

I added my animation to the Animator in the Full Body Layer Sword Sub-state, with the correct transitions (at least I think so, I looked at the ones you made for the demo and learned how it worked). There are some IDs I don't really grasp yet but they aren't related to my issues.

From that point how do I make my combos? I tried two different ways and they both have issues.

1) Use one melee weapon component and one use Item ability. The Melee Weapon Use Animator Audio has a "Sequence" selector with a reset delay of 0.5 and 5 Animator Audio States each with an Item Substate matching their animation. When I tried that my character would no longer start attacking (ever) once I past the second strike for the first time.

2) I tried having 5 melee weapon component and 5 use item ability. This has a similar problem that my character won't attack anymore if I stop attacking before the combo completes. There is also a problem where the character gets stuck at the end frame of an animation, which means my character can't move anymore.

Am I tackling this problem in the wrong way? How would you do it? Why does my character get stuck or stops attacking?

As you can see in the animation above the strike timings vary greatly between strikes so using the "reset delay" variable is not a good option... or maybe it is, if I use states and change the value for each strike (just thought of that now). But one thing I am not sure is if the "reset delay" is re-evaluated after each strike or from the first one. If it's from the first one then it won't work.

The second option I tried was a pain to set up and it won't be viable once I make more weapons with different combo animations.

Once I figure out what is going wrong I will go on to making more complex combo stuff.
With option 1 I have a tiny problem, which is I would like to set the state index externally.

For it to make more sense I need to explain how I want combos to work in my game. I want multiple weapon types: small light sword, huge heavy sword, etc... each weapon type would have a different combo strike count example light sword 5 and heavy sword 3. I would like to have the ability to switch weapons mid combo (after any strike) and continue the combo with the next weapon. Of course, I want to manually set the strike relationship for each weapon type. So for example, I could have the player do a combo a 4 strike combo with three weapons and have: light sword strike 1, switch to spear strike 3, 4, switch to heavy sword strike 3, combo ends. I hope that makes sense.

So just wondering how would you solve this? I assume I'll have to make my own UsableItem extension. Or maybe I should create my class from scratch and use the IUsableItem interface? stuff like damage is data that I would like to get from the ItemType which is specified in the Item component attached on the same gameobject. This way I will be able to use the same prefab for multiple itemTypes (silver light sword, gold light sword, XXX light sword, etc...). I'll eventually like to add elemental damage with enemies being resistant to some elements and item types but I'll deal with that later.

One last thing. How does the ability priority work for character abilities and item abilites? From what I understand item abilities have priority over character abilities. For example, you can't jump in the middle of an attack. I will eventually want to make a dodge ability which can be activated anytime (even in the middle of a strike), it would have a little cooldown though, how would I do that? I'm thinking that I should look at the fall ability since it can happen in the middle of an attack (It actually happened before and my character got stuck in the end frame of the attack animation).

Sorry for the long post and thank you for your help
 

Justin

Administrator
Staff member
There are some IDs I don't really grasp yet but they aren't related to my issues.
You're talking about the Animator Audio State Set parameter IDs? Each one of these specify which value the SlotXItemSubstateParameter should be set to so the animator knows when to change to the next combo.

1) Use one melee weapon component and one use Item ability. The Melee Weapon Use Animator Audio has a "Sequence" selector with a reset delay of 0.5 and 5 Animator Audio States each with an Item Substate matching their animation. When I tried that my character would no longer start attacking (ever) once I past the second strike for the first time.
That is the correct route. The Melee Weapon page has a pretty good description of how the combo system works, but the best way to debug this is to enable Debug Animator Controller on the Animator Monitor and see what state the character is getting hung up on. You can also log the Item Ability/Events in order to get a better idea of what is going on.

I would like to have the ability to switch weapons mid combo (after any strike) and continue the combo with the next weapon.
Right now this isn't possible but I have gotten a few request to be able to do something like this. I'd have to really sit down and experiment what the best route would be for this but it'll either be to modify the Use or Melee Weapon class.

How does the ability priority work for character abilities and item abilites?
They are two independent systems, with item abilities having the slight difference in that they don't have a priority to them.
 
Ok thank you. So after following your instructions, I realised that my animation events and my animator were not set up correctly. Now it works:

SwordAttackComboInGame2.gif

My new problem is that my character is super hard to control because he moves all over the place. I want my character to always attack towards the enemy. If he is far he should move towards it rapidly. If the enemy is close the character should stick to it and not go through or start rotating around him.

Any ideas on how I could achieve that? something like in god of war:


Or kingdom hearts:


I can't tell if the enemy moves with the character or if he is simply pushed by the character collider. In any case I think the enemy and character position/rotation is affected by one another.
 

Justin

Administrator
Staff member
Are you using root motion? If so the movement is driven by that, otherwise it is driven by the motor acceleration values. If one character runs into another character it will not move that second character unless you explicitly add a force to that other character.
 
Ok, since I can't find any documents/guides on how to create this sort of combat mechanic, I think I'll just try things out myself by breaking it down in small pieces. Since I only have time to work on my game during the weekend I will do this step by step.

So the first step is a locking mechanism. I see that there's an aim assist /aim assist handler but they work with crosshairs, so I'm not sure if it's useful for the melee combat I am going for. On top of that, I am using cinemachine, which I'm not sure if it works with the aim assist.

I would like to end up with a similar thing as the KH gif above, where the character has an automatic lock-on (only affect attack orientation/rotation) and a manual lock, which also turns the camera to keep the target in the center of the screen.

I found this UE4 asset, which is more or less what I would like to implement:


I'm wondering if you have any advice on how I should deal with the camera movement to face enemies if I make my own locking mechanism and use the cinemachine view type?

At the end of the weekend I'll post my progress. Hopefully, this thread will help other people who will try to implement a melee action game.
 

Justin

Administrator
Staff member
I'm wondering if you have any advice on how I should deal with the camera movement to face enemies if I make my own locking mechanism and use the cinemachine view type?
You're right - the Cinemachine view type is not able to use the AimAssist component. I have added it to my list to look at.

In version 2.1.2 I have created a new ability called Target Orbit which may help your situation. The target orbit ability does not require the AimAssist component and it'll keep a character rotated towards a particular transform. I created this ability because I noticed the Dodge ability from the upcoming Agility Pack was drifting away from the target even though the AimAssist component was locked on.
 
Ok, I'm not sure if the orbit ability is what I want (it might be depending on if I go more Zelda like, than KH like lock-on), but I'll definitely try it out when it comes out.
 
After playing a few games during the weekend, I decided to go with a LockOn system similar to Nier Automata.

I have an automatic LockOn (yellow cursor in video) and a manual lockOn(red cursor in video). When I manually LockOn, the camera slowly orient itself towards the target. The character is still free to move around and rotate the camera with the mouse/joystick.

Here is what I have gotten so far:

https://drive.google.com/file/d/1UF96lbz8lQRmjmUZKwa0nplQ0pBUgnv4/preview

It still has issues and I asked some help on the cinemachine forum. There's a few things which are giving me problems.

Two of them is the LockOn cursor.
1) I would like to draw the cursor on the target, and I would like the cursor to always stay the same size and keep the same orientation. Currently, I draw it on top of the screen, but if the target is behind the enemy, the cursor is drawn on top of the character. Instead, I want the cursor to be drawn only on the enemy. any ideas how?
2) the cursor is drawn in Update, before the camera movement, so when I move the camera the cursor doesn't always stay on the target. I tried updating in LateUpdate but it didn't change anything. Any ideas on how to fix this?

I know it's not related to TPC but I'm just asking in case you know an easy fix.

Once I succeed the result I want I'll share how I made it.

The end goal is to have animation events on the attacks that simply rotate the character to face the target at specific frame intervals of the attack animation. This way I never miss my attacks (except if the character is too far from the target).
 

Justin

Administrator
Staff member
Progress!

1. This looks like it would be a world space UI for the cursor.
2. Have you checked the execution order? You'll want to ensure the cursor is drawn after the Camera Controller updates.
 
Top