Struct AnimatedModelInstance
Lightweight per-entity state for an animated model (Flyweight extrinsic state). Playback lives here (~20 bytes); mesh/clips live on the shared AnimatedModelData.
Pose and draw are adjacent: Update(float) only advances the frame, Draw(Vector3, Vector3, Vector3, Color)
uploads bone matrices then draws. Never call Raylib.UpdateModelAnimation on a GPU-skinned
model — that writes posed vertices into the VBO, and the shader then skins them again
(collapsed/exploded mesh).
public struct AnimatedModelInstance
- Inherited Members
Constructors
AnimatedModelInstance(AnimatedModelData)
public AnimatedModelInstance(AnimatedModelData data)
Parameters
dataAnimatedModelData
Properties
AnimationSpeed
Playback speed multiplier (1.0 = normal speed).
public float AnimationSpeed { readonly get; set; }
Property Value
CurrentAnimIndex
Index of the currently active animation.
public int CurrentAnimIndex { readonly get; set; }
Property Value
CurrentFrame
Current frame in the active animation.
public int CurrentFrame { readonly get; set; }
Property Value
Data
Reference to the shared model and animation data.
public readonly AnimatedModelData Data { get; }
Property Value
IsLooping
Whether the animation loops or plays once.
public bool IsLooping { readonly get; set; }
Property Value
IsPlaying
Whether the animation is currently playing.
public bool IsPlaying { readonly get; set; }
Property Value
IsValid
True if the underlying shared data is valid and not disposed.
public readonly bool IsValid { get; }
Property Value
Methods
ApplyPose()
Pushes this instance's current frame onto the shared model.
public void ApplyPose()
Remarks
Call immediately before drawing when several instances share one AnimatedModelData. The palette for a frame is built once and copied onto the model, so the last copy is the one that draws. The CPU fallback re-skins every vertex.
Draw(Vector3, Vector3, Vector3, Color)
Renders the model with the current animation pose.
public void Draw(Vector3 position, Vector3 rotationDeg, Vector3 scale, Color tint)
Parameters
positionVector3The position to render at.
rotationDegVector3The rotation in degrees around each axis.
scaleVector3The scale to apply.
tintColorThe color tint to apply.
PlayAnimation(int)
Starts playing the animation at the specified index.
public void PlayAnimation(int animIndex)
Parameters
animIndexintThe index of the animation to play.
Exceptions
- ArgumentOutOfRangeException
Thrown if animIndex is invalid.
PlayAnimation(string)
Starts playing the animation with the specified name.
public void PlayAnimation(string animName)
Parameters
animNamestringThe name of the animation to play.
Exceptions
- ArgumentException
Thrown if the animation name is not found.
StopAnimation()
Stops the current animation playback.
public void StopAnimation()
Update(float)
Updates the animation playback based on elapsed time.
public void Update(float deltaTime)
Parameters
deltaTimefloatTime elapsed since the last update.