Skip to content

Animation

Summary

This page summarizes all aspects of the animation system, which is responsible for bringing objects in the scene to life.

Design decisions

This template makes the following design decisions regarding the default way Unity handles animation:

Animation system

This project uses Unity's default built-in animation system, known as the Mecanim Animation system, to bring its in-game units to life.

animation_system.png

Animation folder

The non-code files in this section are at BeatEmUpTemplate/Assets/Animation.

animation_animation_folder.png

MecanimAnimation

The non-code files in this section are in the MecanimAnimation subfolder.

AnimationClips

animationclips.png

AnimationClips are imported from an external source or created within Unity. They are then placed and arranged in an AnimatorController.

AnimatorControllers

animatorcontrollers.png

AnimatorControllers use state machines to determine what AnimationClip to play. They are referenced by the Animator components on the Hero and Villain prefabs.

Scripting folder

The code files in this section are at BeatEmUpTemplate/Assets/Scripting/Animation.

animation_scripting.png

StateMachineBehaviours

These scripts are components that can be added to a state machine state. All classes in this folder derive from Unity's base StateMachineBehaviour class.

BoolClearedByIPauseAnimatorUnpauseAnimator

classDiagram
    class BoolClearedByIPauseAnimatorUnpauseAnimator{
    }

BoolClearedByIPauseAnimatorUnpauseAnimator.cs defines a bool parameter to be cleared if the UnpauseAnimator event is fired by an IPauseAnimator interface implementation.

BoolSetByAbility

classDiagram
    class BoolSetByAbility{
    }

BoolSetByAbility.cs define a bool parameter to be set if the SetAnimationBool event is fired by an IRaiseSetAnimationBool interface implementation. It also listens for when new abilities are added via a unit's AbilityManager.

BoolSetByIDamageableDamaged

classDiagram
    class BoolSetByIDamageableDamaged{
    }

BoolSetByIDamageableDamaged.cs defines a bool parameter to be set if the Damaged event is fired by an IDamageable interface implementation.

BoolSetByIDamageableDamagedBack

classDiagram
    class BoolSetByIDamageableDamagedBack{
    }

BoolSetByIDamageableDamagedBack.cs defines a bool parameter to be set if the DamagedBack event is fired by an IDamageable interface implementation.

BoolSetByIDefeatableDefeated

classDiagram
    class BoolSetByIDefeatableDefeated{
    }

BoolSetByIDefeatableDefeated.cs defines a bool parameter to be set if the Defeated event is fired by an IDefeatable interface implementation.

BoolSetByIDefeatableDefeatedBack

classDiagram
    class BoolSetByIDefeatableDefeatedBack{
    }

BoolSetByIDefeatableDefeatedBack.cs defines a bool parameter to be set if the DefeatedBack event is fired by an IDefeatable interface implementation.

BoolSetByIPauseAnimatorPauseAnimator

classDiagram
    class BoolSetByIPauseAnimatorPauseAnimator{
    }

BoolSetByIPauseAnimatorPauseAnimator.cs defines a bool parameter to be set if the PauseAnimator event is fired by an IPauseAnimator interface implementation.

BoolSetByIRaiseMoveExecutedMovement

classDiagram
    class BoolSetByIRaiseMoveExecutedMovement{
    }

BoolSetByIRaiseMoveExecutedMovement.cs defines a bool parameter to be set if the MoveExecuted event is fired with a non-zero vector by an IRaiseMoveExecuted interface implementation.

BoolSetByIRaiseMoveExecutedNoMovement

classDiagram
    class BoolSetByIRaiseMoveExecutedNoMovement{
    }

BoolSetByIRaiseMoveExecutedNoMovement.cs defines a bool parameter to be set if the MoveExecuted event is fired with a zero vector by an IRaiseMoveExecuted interface implementation.

BoolSetByIRaiseMoveExecutedNonPositiveYMovement

classDiagram
    class BoolSetByIRaiseMoveExecutedNonPositiveYMovement{
    }

BoolSetByIRaiseMoveExecutedNonPositiveYMovement.cs defines a bool parameter to be set if the MoveExecuted event is fired with a non-positive y-vector by an IRaiseMoveExecuted interface implementation.

BoolSetByIRaiseMoveExecutedPositiveYMovement

classDiagram
    class BoolSetByIRaiseMoveExecutedPositiveYMovement{
    }

BoolSetByIRaiseMoveExecutedPositiveYMovement.cs defines a bool parameter to be set if the MoveExecuted event is fired with a positive y-vector by an IRaiseMoveExecuted interface implementation.

BoolSetByIRaiseWonWon

classDiagram
    class BoolSetByIRaiseWonWon{
    }

BoolSetByIRaiseWonWon.cs defines a bool parameter to be set if the Won event is fired by an IRaiseWon interface implementation.

BoolSetByJumpAbility

classDiagram
    class BoolSetByJumpAbility{
    }

BoolSetByJumpAbility.cs defines a bool parameter to be set if the SetAnimationBool event is fired by a Jump ability.

The difference between this script and BoolSetByAbility is that it correctly subscribes to the Jump ability even when two abilities are attached to the player's character at the same time. In the case of this template, even when the player is BeltScrollMoving.

BoolSetOnAnimationFinished

classDiagram
    class BoolSetOnAnimationFinished{
    }

BoolSetOnAnimationFinished.cs defines a bool parameter to be set when the current state's animation finishes.

BoolSetOnStateExited

classDiagram
    class BoolSetOnStateExited{
    }

BoolSetOnStateExited.cs defines a bool parameter to be set when the current state exits.

BoolsSetByIRaiseMoveExecutedNoMovement

classDiagram
    class BoolsSetByIRaiseMoveExecutedNoMovement{
    }

BoolsSetByIRaiseMoveExecutedNoMovement.cs defines multiple bool parameters to be set when the MoveExecuted event is fired with a zero vector by an IRaiseMoveExecuted interface implementation.

BoolsSetOnStateExited

classDiagram
    class BoolsSetOnStateExited{
    }

BoolsSetOnStateExited.cs defines multiple bool parameters to be set when the current state exits.

BroadcastOnStateExit

classDiagram
    class BroadcastOnStateExit{
    }

BroadcastOnStateExit.cs fires a StateExited event when the current state exits.

TriggerSetByTimer

classDiagram
    class TriggerSetByTimer{
    }

TriggerSetByTimer.cs defines a trigger parameter to be triggered when a set amount of time has elapsed.

Structs

These scripts contain user-defined data types that combine fields of different types underneath a single type. All classes in this folder use the struct keyword in their declaration.

BoolParameter

classDiagram
    class BoolParameter{
    <<Struct>>
    }

BoolParameter.cs is used by StateMachineBehaviours to set a bool parameter with name 'name' to value 'value'.