What's the best approach to let mouse movement influence animation?

Sanginius

New member
Hi,

if you want to implement a Mount & Blade like combat behavior, what would be the best implementation for that?

Short explanation for those who don't know Mount & Blade combat:
You basically have 4 attack areas in the game which are defined by the last mouse movement.
If you look right and attack, the attack will come from right, when you look left, the attack will come from left. The same goes for up and down looking as well.

I was thinking to add a new animator parameter that would store the current look direction like "1 = up, 2 = right, 3 = down, 4 = left". In the animator, when the use ability is fired it will check what's the current look direction and play its animations accordingly.

Now to the questions:

* Is the approach with the new animator parameter good, or are there better alternatives?
* How do I change the animator parameter? What's the best approach?
** Will I create an event for the opsive components to change the parameter?
** Will I create just a small MonoBehavior script that does the change on the animator?
** Should I create a new ability that will set a state that I'm then using instead of a new parameter?
* Is there maybe a solution already?

What's probably important to know is, that the AI should later have the same possibilities, so I would probably use some random value to determine where the AI was looking at to make different attack moves.
 
In this situation I would subclass the Use ability so you can decide which animation should play based off of the mouse direction. From here you can set the ItemSubstateIndex parameter within the animator controller. In this case you don't need to add a new parameter because adding parameters properly requires a decent amount of setup.
 
Top