Class AnimationMetaData
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Animation Meta Data is a json type that controls how an animation should be played. Open in GitHub
[DocumentAsJson]
public class AnimationMetaData- Inheritance
- 
      
      AnimationMetaData
- Inherited Members
- Extension Methods
Examples
"animations": [
	{
		"code": "hurt",
		"animation": "hurt",
		"animationSpeed": 2.2,
		"weight": 10,
		"blendMode": "AddAverage"
	},
	{
		"code": "die",
		"animation": "death",
		"animationSpeed": 1.25,
		"weight": 10,
		"blendMode": "Average",
		"triggeredBy": { "onControls": [ "dead" ] }
	},
	{
		"code": "idle",
		"animation": "idle",
		"blendMode": "AddAverage",
		"easeOutSpeed": 4,
		"triggeredBy": { "defaultAnim": true }
	},
	{
		"code": "walk",
		"animation": "walk",
		"weight": 5
	}
]Fields
Animation
The animations code identifier that we want to play
[JsonProperty]
public string AnimationField Value
AnimationSound
[JsonProperty]
public AnimationSound AnimationSoundField Value
AnimationSpeed
The speed this animation should play at.
[JsonProperty]
public float AnimationSpeedField Value
Attributes
Custom attributes that can be used for the animation.
Valid vanilla attributes are:
- damageAtFrame (float)
- soundAtFrame (float)
- authorative (bool)
[JsonProperty]
[JsonConverter(typeof(JsonAttributesConverter))]
public JsonObject AttributesField Value
BlendMode
The animation blend mode. Controls how this animation will react with other concurrent animations. Also see ElementBlendMode to control blend mode per element.
[JsonProperty]
public EnumAnimationBlendMode BlendModeField Value
ClientSide
If true, the server does not sync this animation.
[JsonProperty]
public bool ClientSideField Value
Code
Unique identifier to be able to reference this AnimationMetaData instance
[JsonProperty]
public string CodeField Value
CodeCrc32
public uint CodeCrc32Field Value
EaseInSpeed
A multiplier applied to the weight value to "ease in" the animation. Choose a high value for looping animations or it will be glitchy
[JsonProperty]
public float EaseInSpeedField Value
EaseOutSpeed
A multiplier applied to the weight value to "ease out" the animation. Choose a high value for looping animations or it will be glitchy
[JsonProperty]
public float EaseOutSpeedField Value
ElementBlendMode
A way of specifying BlendMode per element.
[JsonProperty]
public Dictionary<string, EnumAnimationBlendMode> ElementBlendModeField Value
ElementWeight
A way of specifying Weight for each element. Also see ElementBlendMode to control blend modes per element..
[JsonProperty]
public Dictionary<string, float> ElementWeightField Value
FpVariant
public AnimationMetaData FpVariantField Value
HoldEyePosAfterEasein
A value that determines whether to change the first-person eye position for the camera. Higher values will keep eye position static.
[JsonProperty]
public float HoldEyePosAfterEaseinField Value
MulWithWalkSpeed
Should this animation speed be multiplied by the movement speed of the entity?
[JsonProperty]
public bool MulWithWalkSpeedField Value
StartFrameOnce
public float StartFrameOnceField Value
SupressDefaultAnimation
Should this animation stop default animations from playing?
[JsonProperty]
public bool SupressDefaultAnimationField Value
TriggeredBy
Controls when this animation should be played.
[JsonProperty]
public AnimationTrigger TriggeredByField Value
WasStartedFromTrigger
public bool WasStartedFromTriggerField Value
Weight
The weight of this animation. When using multiple animations at a time, this controls the significance of each animation. The method for determining final animation values depends on this and BlendMode.
[JsonProperty]
public float WeightField Value
WeightCapFactor
This property can be used in cases where a animation with high weight is played alongside another animation with low element weight.
In these cases, the easeIn become unaturally fast. Setting a value of 0.8f or similar here addresses this issue.
- 0f = uncapped weight
- 0.5f = weight cannot exceed 2
- 1f = weight cannot exceed 1
[JsonProperty]
public float WeightCapFactorField Value
WithFpVariant
[JsonProperty]
public bool WithFpVariantField Value
Properties
AdjustCollisionBox
[JsonProperty]
public bool AdjustCollisionBox { get; set; }Property Value
Methods
Clone()
Not a deep clone of all fields. Scalar fields, for example AnimationSpeed, are fresh copies and can be changed dynamically or per-entity, after cloning the AnimationMetaData.
 For performance reasons, the non-scalar fields such as the Attributes, ElementWeight, ElementBlendMode and TriggeredBy are not deep-cloned as these fields are usually unchanging for all entities using the animation.
 Note: If any implementing entity needs to change the non-scalar fields dynamically, or on a per-entity basis, that entity's code can clone and replace the object in its own individual copy of the AnimationMetaData.  e.g. EntityDrifter replaces .TriggeredBy in some of its animations
public AnimationMetaData Clone()Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)Parameters
- objobject
- The object to compare with the current object. 
Returns
FromBytes(BinaryReader, string)
public static AnimationMetaData FromBytes(BinaryReader reader, string version)Parameters
- readerBinaryReader
- versionstring
Returns
GetCrc32(string)
public static uint GetCrc32(string animcode)Parameters
- animcodestring
Returns
GetCurrentAnimationSpeed(float)
public float GetCurrentAnimationSpeed(float walkspeed)Parameters
- walkspeedfloat
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()Returns
- int
- A hash code for the current object. 
Init()
public AnimationMetaData Init()Returns
Matches(int)
public bool Matches(int currentActivities)Parameters
- currentActivitiesint
Returns
ToBytes(BinaryWriter)
public void ToBytes(BinaryWriter writer)Parameters
- writerBinaryWriter