Animation system
Playing animations for the relatively high amounts of units required in an RTS game can be tricky from a performance point of view. Skeletal meshes require lots of CPU frame time on the game thread, and will issue lots of draw calls which also slows down the render thread. Fortunately, a number of solutions are available to Unreal developers, including Vertex Animated Textures, and our current setup, Turbosequence, a high-performance animation system that computes bone transforms in worker threads and renders units as instanced static meshes through Niagara, reducing significantly the amount of draw calls required.
Even if Turbosequence renders meshes with very nice quality, there are some drawbacks, so we still use skeletal meshes for entities that are reduced in number and can benefit from higher quality rendering. Those include heroes and monsters, for example.
Since we wanted to be able to support both animation systems, we designed an architecture that would detach the animation logic (when to play an animation, how to transition between them, blending, speeding up/slowing down, freezing, etc) from the actual immplementation of the concrete animation. In this way we can reuse almost all the animation logic without caring is units use Turbosequence or Skeletal meshes. If we need to add another animation system, we just need to write the implementation and the logic will keep working the same.
Animation Controller Component
The main logic class for animations in the animation controller component. The flow to switch an animation is as follows:
SwitchAnimation(ERTSAnimEnum NewAnimation, const TArray<UAnimSequence*>& OverrideAnimationAssets, float OverridePlaySpeed)
A new animation is triggered. This is the entry point and external classes will call this function to try to switch animation. An optional array of overridden animations can be passed. For example, attack animations use this override because each weapon can use different animations to attack.
Optionally we can also pass an override for play speed, in case we need to play the animation faster or slower, for example under the influence of an attack speed boost.
- ``