Menu
Lumberyard
User Guide (Version 1.13)

Simple Animation

Component entity system is in preview release and is subject to change.

The Simple Animation component provides basic animation functionality for the entity. If the entity has a mesh component with a skinned mesh attached (.chr or .cdf file), the Simple Animation component provides a list of all valid animations as specified in the associated .chrparams file. The Simple Animation component does not provide interaction with the Mannequin system and should be used only for light-weight environment or background animation.

Ensure that the layer ID is set up correctly when assigning multiple animations to one component. Animations on higher layers override animations on lower layers.

Simple Animation Component Properties

The Simple Animation component has the following properties:

Animation Name

Name of the animation played by this component on this layer in the absence of an overriding animation.

Layer ID

Layer ID that this animation is to be played on. Animations can override each other if they are not properly authored.

Looping

If selected, animation continues to play in a loop until stopped.

Playback speed

Speed of the animation playback.

Layer weight

Weight of animations played on this layer.

Animate root

Enables animation-driven root motion during playback of this animation.

EBus Request Bus Interface

Use the following request functions with the EBus interface to communicate with other components of your game.

For more information about using the Event Bus (EBus) interface, see Working with the Event Bus (EBus) System.

StartDefaultAnimations

Plays the default animations with default looping and speed parameters that were set up as a part of this component. The component allows for multiple layers to be set up with defaults; this method allows the playback of configured playback layers simultaneously.

Parameters

None

Return

Result indicating whether animations started successfully.

scriptable

Yes

StartAnimationByName

Plays the animation with the specified name on the specified layer.

Parameters

name – The name of the animation to play

layerId – The layer in which to play the animation

Return

Result indicating whether animations started successfully.

scriptable

Yes

StartAnimation

Plays the animation as configured by the animatedLayer.

Parameters

animatedLayer – A layer configured with the animation that is to be played on it.

Return

Result indicating whether animations started successfully.

scriptable

Yes

StartAnimationSet

Plays a set of animations as configured by each AnimatedLayer in the animationSet.

Parameters

animationSet – An AnimatedLayer::AnimatedLayerSet containing animations to be kicked off simultaneously.

Return

Result indicating whether animation set started successfully.

scriptable

No

StopAllAnimations

Stops all animations that are being played on all layers.

Parameters

None

Return

Result indicating whether animations stopped successfully.

scriptable

Yes

StopAnimationsOnLayer

Stops the animations currently playing on the indicated layer.

Parameters

layerId – ID for the layer that is to stop its animation (0,AnimatedLayer::s_maxActiveAnimatedLayers-1).

Return

Result indicating whether animations stopped successfully.

scriptable

Yes

StopAnimationsOnLayers

Stops the animations currently playing on the indicated layers.

Parameters

layerIds – A bitset indicating layers to stop animating.

Return

Result indicating whether animations stopped successfully.

scriptable

No

EBus Response Bus Interface

Use the following response functions with the EBus interface to communicate with other components of your game.

For more information about using the Event Bus (EBus) interface, see Working with the Event Bus (EBus) System.

OnAnimationStarted

Informs all listeners about an animation being started on the indicated layer.

Parameters

animatedLayer – Animated layer indicating the animation and the parameters used to start the animation.

Return

None

scriptable

Yes

OnAnimationStopped

Informs all listeners about an animation being stopped on the indicated layer.

Parameters

animatedLayer – Animated layer indicating the animation and the parameters used on the animation that was stopped.

Return

None

scriptable

Yes

Script Examples

The following is an example of the StartAnimation function.

local startanimation = { Properties = { } } function startanimation:OnActivate() -- Start by playing the idle animation. -- Layer=0, looping = True, speed=1.0, blendtime= 0.0 local animInfo = AnimatedLayer("anim_chicken_idle", 0, true, 1.0, 0.0) SimpleAnimationComponentRequestBus.Event.StartAnimation(self.entityId, animInfo) end return startanimatio

The following is an example of script using the Request Bus Interface.

local chickenanimcontroller = { Properties = { FlapInterval = { default = 0.5, description = "How often the chicken flaps.", suffix = " sec" }, MoveSpeed = { default = 3.0, description = "How fast the chicken moves.", suffix = " m/s" }, IdlePlaybackSpeed = { default = 1.0, description = "Playback speed for the idle animation." }, FlapPlaybackSpeed = { default = 1.0, description = "Playback speed for the flap/jump animation." }, FlapBlendTime = { default = 0.2, description = "Blend time for the flap animation." }, Test1 = { Vector3(1,2,3), Vector3(1,2,3) }, }, } function chickenanimcontroller:OnActivate() self.FlapCountdown = 0.0; -- For handling tick events. self.tickBusHandler = TickBus.Connect(self); -- Start by playing the idle animation. -- Layer 0, looping, speed=1, no transition time. local animInfo = AnimatedLayer("anim_chicken_idle", 0, true, self.Properties.IdlePlaybackSpeed, 0.0); SimpleAnimationComponentRequestBus.Event.StartAnimation(self.entityId, animInfo); end function chickenanimcontroller:OnTick(deltaTime, timePoint) -- Get current transform local tm = TransformBus.Event.GetWorldTM(self.entityId); -- Play the Flap animation FlapInterval seconds. self.FlapCountdown = self.FlapCountdown - deltaTime; if (self.FlapCountdown < 0.0) then -- Layer 0, non-looping, speed=1, 0.2 transition time. -- If the flap were partial body, we could use Layer 1. local animInfo = AnimatedLayer("anim_chicken_flapping", 0, false, self.Properties.FlapPlaybackSpeed, self.Properties.FlapBlendTime, true); SimpleAnimationComponentRequestBus.Event.StartAnimation(self.entityId, animInfo); self.FlapCountdown = self.Properties.FlapInterval; --Debug.Log("Played the flap"); end -- Adjust translation forward at the configured movement speed. local forward = tm:GetColumn(1); local tx = tm:GetTranslation(); tx = tx + forward * deltaTime * self.Properties.MoveSpeed; tm:SetTranslation(tx); -- Set our new transform. TransformBus.Event.SetWorldTM(self.entityId, tm); end function chickenanimcontroller:OnDeactivate() self.tickBusHandler:Disconnect(); end return chickenanimcontroller;