StateAnimationComponent

Specifies the animation to be played by state changes.

# Properties

[{"index":"SyncDictionary ActionSheet (Sync)","0":"The table the animation's name and AnimationClip are mapped to. Used when IsLegacy's value is true."}]

##### inherited from Component:

[{"index":"boolean Enable (Sync)","0":"Checks whether Component is activated or not."}]

[{"index":"boolean EnableInHierarchy (ReadOnly) (HideFromInspector)","0":"Displays whether this Component is Enable in the hierarchy. If Entity Enable is false regardless of Component Enable, returns false."}]

[{"index":"Entity Entity (ReadOnly)","0":"The Entity that owns this component."}]

# Methods

[{"index":"void ReceiveStateChangeEvent(IEventSender sender, StateChangeEvent stateEvent) (ScriptOverridable)","0":"Function which handles StateChangeEvent upon receiving. AnimationClipEvent is raised to play AnimationClip which is basically mapped to a State."}]

[{"index":"void RemoveActionSheet(string key)","0":"Removes the element corresponding to key in StateToAvatarBodyActionSheet. Removes the element from ActionSheet if IsLegacy's value is true."}]

[{"index":"void SetActionSheet(string key, string animationClipRuid)","0":"Adds elements to StateToAvatarBodyActionSheet. AvatarBodyActionStateName's property value of the AvatarBodyActionElement entity added as an element is animationClipRuid, and PlayerRate's property value is 1. Adds an element to ActionSheet when IsLegacy's value is true."}]

[{"index":"string StateStringToAnimationKey(string stateName) (ScriptOverridable)","0":"Returns the name of mapped Animation to the State."}]

##### inherited from Component:

[{"index":"boolean IsClient()","0":"Returns whether the current execution environment is a client or not."}]

[{"index":"boolean IsServer()","0":"Returns whether the current execution environment is a server or not."}]

# Events

[{"index":"AnimationClipEvent","0":"This event occurs when AnimationClip change is required."}]

# Examples

This example makes a monster display a random hit animation. You can test it by deleting the monster's basic StateAnimationComponent and adding the following Component, which is an extended StateAnimationComponent. When attacking a monster after playing, you can see Orange Mushroom's various hit animations.

Since the `StateStringToAnimationKey()` function is called when an animation needs to play, `SetRandomHitAnimation` is called in advance. By setting a random animation clip to the `hit` animation key, the set animation clip will be played when playing the `hit` animation
    
    
    @Component
    script HitAnimationRandomizer extends Component
        property table HitAnimations = {}
    
        method void OnBeginPlay()
        table.insert(self.HitAnimations, "000000")
        table.insert(self.HitAnimations, "000000")
        table.insert(self.HitAnimations, "000000")
        table.insert(self.HitAnimations, "000000")
        end
    
        method void SetRandomHitAnimation()
        self:SetActionSheet("hit", self.HitAnimations[_UtilLogic:RandomIntegerRange(1, #self.HitAnimations)])
        end
    
        override method string StateStringToAnimationKey(string stateName)
        if stateName == "HIT" then
        	self:SetRandomHitAnimation()
        end
    
        return __base:StateStringToAnimationKey(stateName)
        end
    end
    

# SeeAlso

  * UtilLogic
  * table