> For the complete documentation index, see [llms.txt](https://docs.msquared.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.msquared.io/creation/unreal-development/features-and-tutorials/the-animated-crowd/crowd-animation.md).

# Crowd Animation

## Overview

Crowd members can be animated in two ways

* By setting animation sequences directly on the crowd member themselves
* By using an Animation Blueprint (ABP)

These techniques can be used either together or in isolation.

{% hint style="info" %}
If an animation sequence is specified directly on a crowd member it will take precedence over the ABP animation until the override is removed. The ABP will continue to update in the background however.
{% endhint %}

## Animation Data Setup

In order to use an Animation Blueprint with the crowd it must first be configured to be compatible. More details on ABP setup can be found [here](/creation/unreal-development/features-and-tutorials/the-animated-crowd/crowd-animation/crowd-anim-blueprint.md).

Both animation inputs methods are configured via setting the `AnimNameToSequence` map.

This can be done in one of two ways:

### Via the render target pawn

{% hint style="info" %}
This option is only available in v40 onwards
{% endhint %}

Where possible, the animated crowd obtains data from the LOD0 render target actor class, e.g. the skeleton and the anim instance. We also enable it to provide the `AnimNameToSequence` map, so it can specify what anim sequences it needs to support.

If your LOD0 class implements the `CrowdAnimationProviderInterface` (this is done automatically for children of the `M2_CharacterBase`), then it will expose a `GetAnimNameToSequenceMap` function, which can provide the list of anim sequences.

### Via the Crowd Data

If your animated crowd provides a `Skeletal Animated Crowd Data` data asset, you can fill in the `AnimNameToSequence` map there.

<figure><img src="/files/Sckr7ETf6YLRwTejnIYl" alt=""><figcaption><p>Example Skeletal Animated Crowd Data specifying ABP driven animations as well as named sequences</p></figcaption></figure>

In the above example, an ABP is connected via the `Crowd Anim Instance` parameter and additionally a list of named sequences are supplied in the `Anim Name to Sequence` list.

## Selecting An Animation Source On A Crowd Member

Animation setup for each crowd member is specified by configuring properties within its `FAnimatedCrowdMemberState` .

Animation selection is performed as follows

1. If a crowd member has `FAnimatedCrowdMemberState::AnimState` specified
   * The named animation will be play back on that crowd member
   * If a name isn't specified (`NAME_None`) or it isn't found in the `Anim Name to Sequence list`, then we go to the next step and check the ABP
2. If a crowd has an ABP specified
   * `FAnimatedCrowdMemberState::AnimFloatParameters` will be updated for the crowd member - these contain the anim vars used to drive things like ABP state logic
   * Crowd member will play back ABP driven animation
3. If there was no animation sequence set directly and ABP wasn't present
   * Crowd member will be set to ref pose and will render, but not animate
