Hello,
I have a simple problem yet I can’t find any usable solution.
My scenario: I have 8 animations for a player to turn on the spot (45, 90, 135, 180 degrees to the right and left). I have placed them all into a 1D blend-space with axis denoting a turning angle. Then, in the code, I specify the turning angle and my state machine correctly transitions into the turn state, blends in the blend-space and my player character turns – everything looks nice and dandy.
My problem is that because of the player input (or network input) the player might want to change his target direction while already turning. In another game engines (or custom animation systems) it would be solved by playing another blend-space over the current one (with a different turn angle set). Therefore “layering” one animation over itself. However, it is not possible in Unreal because there is just a state machine with specific number of states (and transition conditions).
I was thinking about various solutions to my problem:
- The simplest way is to disable handling of the new turn while already in turning animation. However this adds a lot of latency to the player control – if player is currently turning 180 degrees and he changes his mind he must wait. No good.
- Add new “turn” states. Detect that the character is currently in the turn state and transition into a next available turn state. This is doable even though not much elegant solution. The problem is that the blend-space node with turning animations is reading some exposed “Turn angle” variable which is only one. Therefore even this variable must be doubled, tripled, quadrupled… copied as many times turning animation could play over itself. This make the code less elegant.
- Use montages and slots, somehow. Create dedicated slots for every turning – as many slots as there could be layered turning animations. Problem is that montages cannot contain blend spaces therefore I don’t know how to blend between montages to achieve the same result as with blend spaces.
Did anyone encountered the same problem? I know that the turning animation is just one example. The same problem might arise when (for example) combat animations should link one after another: same punch or kick blended over again and again.
Did you find a solution which suits your game?
Thank your for any suggestions.
P.S.: I was also thinking about programming some custom animation node with a queue of blended blend-spaces which would perform some inner blending itself. However it seems to me rather radical – like doing own animation system within an existing one.
Addendum:
I’m currently working on another solution.
- The use of blend-by-int node (or some custom derived version). In the state, instead of using the single blend-space node I added a blend-by-int node with many blend-spaces (containing my turning animations). In the code I detect that my character is already turning when a new turn request arrives. Then I change the index to blend in a different turning animation. To keep all turning angles intact, I specify an array of turning angles which are all set as an axis values to blend-space nodes. The problem is with animation end detection – during the blending to the new turning animation the previous one incorrectly reports the end of animation. This must be handled in the code in some special way (i.e. for some period of time that report is kept as false).