LoadAnimation

Loads one or more animations from a model file, onto an existing entity. The hierarchy in the loaded file must match the hierarchy of the entity.

Syntax

Returns

Returns the index of the first loaded animation. If the file cannot be loaded, or if it contains no animations -1 is returned.

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
local camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Load a model
model = Model:Load("Models/Trees/pine01.mdl")

--Load an animation onto the model
animationsequence = model:LoadAnimation("Models/Trees/pine01@walk.mdl")

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

--Play animation
if (animationsequence>-1) then
model:SetAnimationFrame(Time:GetCurrent()/50.0,1,animationsequence)
end

Time:Update()
world:Update()
world:Render()
context:Sync()
end