Skip to content
CISV2.0GET IT ON FAB

SYSTEMSANIMATION HELPERS

Animation helpers

The animation helpers are two classes that a montage or an animation and a Blueprint can use without other code. UCISAnimNotifyStateAttachMesh is an anim notify state that attaches a static mesh to a socket of the skeletal mesh that plays the animation, for the length of the notify. UCISRootMotionMovementTask is an async action that moves a character to a point with a root motion source, and reports when the move ends. The demo’s move handlers use the second one to walk the character to the point of a side.

  • UCISAnimNotifyStateAttachMesh attaches Mesh to Attach, a static mesh, to the socket named by Socket Name when the notify begins, and removes it when the notify ends. It is an anim notify state, so it runs in the animations that a skeletal mesh plays.
  • UCISRootMotionMovementTask moves a character to a target location with a root motion source. It starts from Blueprints with RootMotionMoveTo, and it raises three events: when the move is created, when it finishes, and when its time runs out.
  • The demo’s example of the notify is the animation /CharacterInteractionSystem/Demo/Animations/Character/Door/Man_KeyDoorOpen, which carries a notify of this class.

The attach notify. When the notify begins on a skeletal mesh, it spawns a static mesh component under the actor that owns that mesh. The component takes Mesh to Attach as its mesh and attaches to the skeletal mesh at Socket Name, snapping to the socket’s location and rotation but not its scale. The notify keeps one such mesh for each skeletal mesh that plays the animation, because one notify object is shared by all of them. When the notify ends, the mesh of that skeletal mesh is destroyed. A second begin on the same skeletal mesh first removes the mesh it spawned before. The notify runs where the animation plays, and the mesh is created there as a component of the skeletal mesh’s actor.

Stale meshes. Each begin and end of the notify first removes the entries whose mesh is gone. An entry whose skeletal mesh is gone without an end, for example one destroyed in the middle of the animation, has its mesh destroyed at that point.

The root motion move. RootMotionMoveTo creates the task with the character as its outer object. When the task activates, it looks for the ground under the target with a line trace of the Collision Check Trace Type channel. If it finds ground, the target becomes the hit point plus the capsule’s half height and Vertical Offset; otherwise the target stays as given. The task sets the character’s movement mode to Movement Mode during the move, and it sets the walk speed to Custom Move Speed when With Custom Move Speed is on. It applies a root motion source that moves the character to the target over the distance divided by the speed, with a least duration of 0.05 seconds. The source is applied to the character’s movement component, and the task has no network call of its own, so the move runs where the task is activated. OnRootMotionMovementCreated runs once the source is applied.

Ending a move. FinishMovement (shown in Blueprints as StopMovement) removes the source, restores the speed and the movement mode, and runs OnRootMotionMovementFinished. The move ends in one of three ways: its source finishes, the character is no longer valid, or its time runs out. When the time runs out, OnRootMotionMovementFinished runs first and OnTimeOut runs after it. With a speed of 0 and a target away from the character, the character is held at its start until Time Out, and then the move times out.

The steps are in the guides, so this page gives only the outline:

  1. For a walk to the point of a side, follow Two-sided door, step 3. It sets the demo move handler BP_MoveToComponentMoveHandler on a side. The demo handler walks the character with RootMotionMoveTo, and it moves only BP_CISCharacter.
  2. No walked guide adds an attach notify. To attach a mesh, add the notify to an animation as described under Use it. The demo’s /CharacterInteractionSystem/Demo/Animations/Character/Door/Man_KeyDoorOpen is an animation sequence, not a montage. It carries one attach notify state from 0.24 s to 1.30 s of its 1.5 s length, which attaches the key mesh /CharacterInteractionSystem/Demo/Meshes/Key/Key at the socket KeySocket.
  • Add the notify to an animation that a skeletal mesh plays, as a notify state of this class. Set Mesh to Attach to the static mesh to show and Socket Name to the socket of that skeletal mesh that the mesh attaches to.
  • Call RootMotionMoveTo in a Blueprint with the character and the target location. Bind OnRootMotionMovementCreated, which passes the task, OnRootMotionMovementFinished, and OnTimeOut to react to the move.
  • Call FinishMovement to end the move before it finishes. It is the StopMovement node in the Blueprint editor.
  • Set Time Out to the longest move time you allow. The default is 2 seconds, and a move that needs longer ends at the time-out before the character arrives.

The attach notify’s two settings are shown in the panel below and in the first two rows of the table. The move’s settings are the parameters of RootMotionMoveTo, listed after them, with their defaults.

Settings
Mesh to AttachNone
Socket Name
The settings of the attach notify: the static mesh to attach and the socket to attach it to.
SettingWhat it doesDefault
Mesh to AttachThe static mesh that the notify attaches for its length. Empty: an empty component is still spawned and attached.None
Socket NameThe socket of the skeletal mesh that the mesh attaches to.None
Target LocationWhere the character moves. The move uses the ground that a trace finds from 5 units above to 500 units below it.No default; it is a required input
Collision Check Trace TypeThe channel of the trace that finds the ground under the target.ECC_WorldStatic
Movement ModeThe movement mode during the move. The character’s previous mode returns at the end.MOVE_Walking
Root Motion Accumulate ModeHow the move’s root motion combines with other root motion.Override
With Custom Move SpeedUses Custom Move Speed instead of the walk speed of the character.Off
Custom Move SpeedThe speed of the move when With Custom Move Speed is on. A speed of 0 holds the character at its start until Time Out.0
Time OutThe longest move time in seconds. A move that needs longer ends at this time, before the character arrives, and OnTimeOut runs.2
Vertical OffsetThe height added to the ground found under the target.0
  • Play the animation in the editor’s preview, or in the level with a character that plays it. The mesh appears at the socket when the notify begins, and it is gone when the notify ends.
  • Call RootMotionMoveTo to a point you can reach. The character walks there, and OnRootMotionMovementFinished runs when it arrives.
  • An empty mesh appears as nothing. With Mesh to Attach empty, the notify still spawns and attaches an empty component at the socket, so nothing is seen. Set Mesh to Attach.
  • The mesh does not appear at the socket. The mesh attaches at Socket Name of the skeletal mesh that plays the animation. Check that the name is a socket of that mesh, and that the animation plays on it.
  • The mesh stays after the animation. The notify removes the mesh at its end. A notify that begins again on the same skeletal mesh before it ends replaces the mesh instead. The mesh of a skeletal mesh that is destroyed in the middle of the animation is removed at the next begin or end of the notify.
  • RootMotionMoveTo gives no task. Its Character input is empty, and the node returns no task. Pass the character that moves.
  • The character does not move with a speed of 0. The character is held at its start until Time Out, by design. Set Custom Move Speed above 0 to move it at that speed.
  • The character stops in the air or below the ground. The target is placed on the ground that the trace finds under it. Check Collision Check Trace Type and Vertical Offset. Without ground under the target, the target is used as given.
  • OnRootMotionMovementFinished runs when the move times out. It does: on a time-out it runs first, and OnTimeOut runs after it. Bind OnTimeOut to tell a time-out from an arrival.
  • The demo’s move does not walk your character. The demo move handlers move only BP_CISCharacter. With another character, the action runs without the walk. See Troubleshooting.