CraftStudio Wiki
CraftStudio Wiki

ModelRenderer:GetAnimation, ModelRenderer:SetAnimation[]

[Animation] ModelRenderer:GetAnimation()
ModelRenderer:SetAnimation( [Animation] animation )

Gets or sets the current animation for this model. It will start playing right away unless you called ModelRenderer:StopAnimationPlayback.

You can get animations to use with SetAnimation by calling CraftStudio.FindAsset

ModelRenderer:StartAnimationPlayback[]

ModelRenderer:StartAnimationPlayback( [boolean] loop=true)

Starts animation playback (provided it was stopped earlier with ModelRenderer:StopAnimationPlayback) or changes the way an animation plays back. Pass false to disable looping.

ModelRenderer:StopAnimationPlayback[]

ModelRenderer:StopAnimationPlayback()

Stops animation playback.

ModelRenderer:SetAnimationTime[]

ModelRenderer:SetAnimationTime( [number] time )

Sets the current animation time (in seconds).

You could call ModelRenderer:StopAnimationPlayback and then use this function to move forward / backward in time in a script.

Model animations are rendered at 30 frames per second. This means you can skip to the 3rd frame on an animation by using ModelRenderer:SetAnimationTime( 3 / 30 ) for instance.

ModelRenderer:IsAnimationPlaying[]

[boolean] ModelRenderer:IsAnimationPlaying()

Returns true if an animation is currently playing.

ModelRenderer:GetModel, ModelRenderer:SetModel[]

[Model] ModelRenderer:GetModel()
ModelRenderer:SetModel( [Model] model to display, [boolean] clear animation=true )

Gets or sets the displayed model. You can get a model to display with CraftStudio.FindAsset.

ModelRenderer:GetOpacity, ModelRenderer:SetOpacity[]

[number] ModelRenderer:GetOpacity()
ModelRenderer:SetOpacity( [number] opacity )

Gets or sets the model renderer's opacity (between 0.0 and 1.0)

ModelRenderer:GetBlockTransform[]

[table] ModelRenderer:GetBlockTransform( [string] block name )

Returns a table with position and orientation keys containing the specified model block's current position and orientation ( "[table].position" and "[table].orientation").

This method is useful for making a weapon or tool follow an arm for instance.