Animation in Armory



In this tutorial, we are going to look at using animations in Armory. The truth of the matter is, using animations is incredibly simple, but creating a compatible Blend file can perhaps be the biggest challenge.

To work around this problem I have provided the simple blend file used in this example. It contains a properly configured Blender file with an armature with two named animations as well as two markers. If you are having issues, download it and start from there.

Let’s start with the easy part, playing an animation using Nodes

Animation using nodes - Armory3D

Yeah, it’s that simple. When the user presses the 1 key, the bend animation is played. When the 2 key is pressed, the Idle animation is played. The node powering it all is the Play Action node with the important parameter being the animation name. The Blend value determines how smoothly the animations are blended when switching from one action to the other. Here is the example running:

Animation Armory3D

It’s also possible to trigger functions using Action Markers as part of the animation. When a marker is hit you can respond by adding whatever logic you want, enabling you do to things like trigger sound effects when the marker is hit, or any other game logic you want to integrate with the animation. Responding to markers is as simple as:

Responding to Markers - Animation Armory3D

The following Haxe code accomplishes the same thing as the above nodes:

notifyOnUpdate(function() {
      if(iron.system.Input.getKeyboard().released("a")){
        trace("Playing animation bend");
        this.object.animation.play("Bend",function(){
          trace("Bend animation done");
          },1.0,1.0,false);
      }
      if(iron.system.Input.getKeyboard().released("b")){
        trace("Playing animation idle");
        this.object.animation.play("Idle",function(){
          trace("Idle animation done");
          },1.0,1.0,false);
      } 
  });

Now the challenge is properly setting up the animations. First off in Blender, you need to set your animations up as actions like the following:

Animation Action - Armory3D

Actions can be created using the NLA Editor in Blender. The details of creating actions is well beyond the scope of this tutorial. If you want a specific tutorial showing how to create actions using Blender, let me know in the comments below. The other thing to note is the red dashed line, those are markers that have been made local. To learn more about creating and working with markers check this link from the Blender documentation. If you encounter a problem with your animation in Armory, chances are it’s your Blender animation and not your Armory code.

 

Scroll to Top