Producing Reactive Combat Animations

Topics Covered:

This behaviour can be found on the generic solver map in the "RunTime Demo Pack" found here:

A brief demo of the behaviour is shown here: Youtube Link

1 - Introduction

1.1 - Basic Combat Cycle

2 - Punching Character

2.1 - Character Blueprint Logic

2.2 - IKinema Rig

2.3 - Animation Blueprint

2.4 - Using curves to blend in and out of IK

3 - Target Character

3.1 - Character Blueprint Logic

3.2 - IKinema Rig

3.3 - Animation Blueprint

3.4 - Using curves to blend in and out of IK

4 - Final Result

1. Introduction:

For this tutorial we will be setting up a combat scenario in game using a very limited number of base animations (4 in total) which will be combined with IKinema's full body IK to produce reactive, dynamic, procedurally generated animation. 

The scenario will consist of one character who delivers a punch and another character who attempts to dodge.

The set up needed going forward can be divided into the following parts. We will have to:

Set up logic to drive the combat cycle: We will need character and animation blueprints corresponding to our two characters in order to drivde the combat cycle and control when certain animations trigger. The basic combat cycle we will be setting up is described below.

Since this set up lies outside of IKinema's RunTime features, this will not be fully covered. We will be including the full demo (found here) so you can investigate the set up further if you so wish (the punching demo can be found on the Generic Solver map). 

Set up IKinema Rigs for both the puncher and target character: This is where we will specify which bones of our character we want to be given target position/orientation that differs from the origional IK. These bones can be given target locations/orientations at runtime and the full body of the character will be modified to meet these demands. 

There is no special tuning of the rigs needed here except enabling position task on the punchee's head and a few tweaks, only default values were used for the rest of the tasks. The rigs will be slightly different from one another since we want to drive the punchers leading fist. 

Generate target locations for specific limbs: Given that we have particular parts of our character which we want to reach specific locations described above. These target locations will be dynamically generated during runtime in our character blueprints that rely in-world locations of character body-parts.

This demo will consist of two specific implementations of IK as follows:

  • We have the punchers hand which we want to be aimed towards and track the targets head as it throws the punch. 
  • We also have the targets head which we want to be whipped backwards once the punch connects. 

The above behaviors requires passing information between characters. For the behavior of the puncher, we will need to fetch the position of the target characters head, and for the behavior of the target, we need to track and pass it the location of the punchers fist.

Set up timings for when you want to blend in and out of IK and original animation: This part of the set up plays a big part in the look and feel of the final result and is where the polishing takes place. 

We will be using curves in persona to blend into the IK as needed as this gives us really fine-grained control of the speed and triggering of this blending.

1.1. The Basic Combat Cycle:

The following animations will be used to create the basic animation loop. The punching and dodging animations will be modified using IK.

  • Dodge Left 
  • Dodge Right 
  • Idle 
  • Punch 

Without any IK, the base combat scenario loops as follows:

  1. Both characters begin in idle. 
  2. Punching character transitions into punching animation. 
  3. Target character transitions into dodge left or right animation. 
  4. Once the punch/dodge animation has finished, each character will transition back to idle 
  5. Go back to step 1. 

This combat loop is shown below.

There are two main components to this fight scene which we can add IK to in order to make it dynamic. The first will be adding IK to the punching character so that it always aims towards the target characters head when punching. The second will be adding IK to the target character so that the body part that gets hit will react to the force.

Combining these in game components with IKinema will result in a puncher who's shots will appear aimed and precise and a character reacting to getting hit, both real time. Each cycle of the combat loop has the potential to be completely unique.

The IK takes place between steps 3-4 in the basic combat loop described above.

With IK, the cycle is as follows:

1. Both characters begin in idle.
2. Depending on RNG, Punching character begins punch animation.
3. Target character begins to dodge left or right.

3a. Punch tracks the targets head as it is moving.
3b. As punch reaches targets head, triggers reaction from target character.
3c. Target character has head move to new location which is along the punching characters arm but offset to simulate a whiplash effect.

4. Both characters blend out of the IK back into the original animations.
5. Each character returns to idle animation.
6. Repeat.

Including IKinema's full body IK the procedurally generated combat is shown below.

2. Punching Character - Generating dynamically aiming punching: 

The important part in this section is how we set up the target position used to drive the punching arm of our combatant. In short we will be attaching a socket to our target characters head and tracking this location during runtime. This is then passed to the punching characters animation blueprint and used as the target location for the punching hand in the IKinema solver.

2.1. Character Blueprint Logic - Punching Character:

This is our punchers character blueprint. We control the flow of the main event loop using AnimNotifys in the animation blueprints of the puncher and target characters to set the value of the various boolean values displayed.

Section One: Here we an accumulator which is used to trigger a combat cycle once every X seconds.

Section Two: Here is where we fetch and update the location of where we want our puncher to aim. This is where we generate the target location which we want our targets leading arm to hit.

For this demo, we want our puncher to consistently strike the target in the head. To do this we will add a socket to the head bone of the target skeleton as shown below. In our punching characters blueprint, we fetch the world position of this socket (converting to the component space of our punching character as needed by the solver) and then use this as the target location for the punching hand task in the IKinema solver found in the animation blueprint of our punching character.

The position of this socket will move with the head of our target character during game play as the character dodges, using Ikinema, our punching character will adapt his punch trajectory accordingly.


We keep the location of the socket updated from the point the punch is fired to the point in which the leading arm is fully extended where we expect the point of contact. We control this timing using AnimNotifys (shown below) in the punching characters animation blueprint. This gives the punching arm a smooth trajectory as the punch follows the target characters head untill the expected point of contact.


Section Three: After the characters leading fist has reached its target location at the "PunchSocket", we then want to transition back into the idle animation ready to send another punch some time in the future. 

2.3. IKinema Rig - Punching Character:

The IKinema Rig for our punching character consists of 10 tasks as shown below. The only task we need to drive directly with a custom target location is the hand. Generating the target location is discussed above in the characters blue print. The bone and constraint settings are all left at their default settings for the purpose of this demo except for the head task. We want the head to be moved by the puncher so we need to tweak the settings of this task since by default the head task only has a look-at rotation task. 

The tasks assigned are as follows:

  • 4x Feet Tasks – On the ball and heel bones of the feet 
  • 2x Knee Tasks – On the knee bones 
  • 1x Hips Task – On the hips bone 
  • 1x Chest Task – On upper chest bone 
  • 1x Head Task – On Head Bone 
  • 1x Hand Task – On the punching hand of the character 

2.4. Animation Blueprint - Punching Character:

Event Graph:

In the event graph of our punching character, we have set up a number of triggers that are needed to drive the complete combat cycle between our two characters. These can be fully explored in the demo project if you wish to see this in-depth. 

One important factor here is how we fetch the Punch Target Location from the character blueprint as we will need this variable in our AnimGraph.


This is where the target location generated in the character blueprint, the IKinema Rig, our characters base animation and IKinema's IK solver come together to procedurally generate new animation.

We fetch our target location that we want the fist to reach (the location in component space of a socket attached to our target characters head). We can also use this location to drive the look-at of our chest and head causing the body to swivel slightly to align the chest/head/hand orientation as the punch is thrown.

2.4. Using curves as alpha values to blend in-and-out of IK - Punching Character:

In this example, we want to blend into our IK as the character begins to throw its punch and then back out of the IK as the character is finished punching. We can do this using curves in persona to generate alpha values to use in the "set up task" node for the leading fist. This alpha value will let us blend in and out of the IK.

As the punch begins to fire, we want to begin a transition into the IK. This will cause the punching fist of our character to begin homing in towards the location of the target characters head. The IKinema solver will also adjust the full body of our punching character to allow this to happen. We want the alpha value to increase to 1.0 as the arm becomes fully extended. At this point, the punching arm will be locked at the target location. This is where we would expect the hit to occur. Proceeding from here we them smoothly transition to an alpha value of 0 as we move from IK back to the original animation.

3. Target Character: Generating Reactive Animation

In principle, the method we used to set up the IK for the punching character will be the same for our target character. It effectively boils down to identifying what parts of the body we want to move, where we want to move these body parts and at what time/over what time scale.

As stated in the introduction, we will be using IK in order to generate a reactive animation as our target gets hit by the puncher. We will be aiming to achieve a whiplash effect on the head as the character is punched. To do this we will attach a socket to the punchers hand that is along the bone but will lie behind the targets head when the punch lands as shown in the images below.

As the punch lands, this will put the socket behind the target characters head. We want this movement to occur when the punch should hit to give the impression that the head is being moved by the force of the punch. The socket used as the target location of the head will produce head movement along the correct line of force.

3.1. Character Blueprint - Target Character:

In our character blueprint we will be fetching the location of the socket attached to the punching characters hand we set up above. This transform will be passed to the target characters animation blueprint and used as the target in the "set up task" node for the constraint we assigned to our characters head bone.

3.2. IKinema Rig - Target Character:

All of the constraints added to this rig keep their default settings and no extra tuning is required. The constraints issued are as follows and shown in the image below:

  • 2 x Feet Tasks – applied to heel joints on feet 
  • 2 x Knee Tasks – applied to knee bones 
  • 1x Hips Task 
  • 1x Chest Task - applied To Upper Chest Bone 
  • 1x Head Task 
    • Disable Look-at in the orientation task settings
    • Enable position task
    • Boost the position/orientation weights to 60/50 respectively
    • Set the position precision to 2 (may have to expand the position task settings fully)

3.3. Animation Blueprint - Target Character:

Event Graph:

Again, much like the punching character animation blueprint, we need to fetch the target location for our target characters head which will be passed in as the position task to our head constraint in the IKinema solver in the AnimGraph.


In our AnimGraph we will be using a simple state machine that transitions between our dodge and idle animations, this can be investigated in further detail in the demo project (found here). The only constraint we are directly driving is the head as shown below.

3.4. Using curves to drive alpha values for blending in and out of IK - Target Character:

For our target character, we want the head snapping backwards on hit to be very sudden. We used a separate curve track in persona to drive the alpha values of the head task beginning just before the puncher has fully extended its arm and fading out relatively slowly over time shown below. We want the fade in to be quicker than the fade out.


4. Final Result: