PlayAnimation
This command makes an entity automatically play an animation sequence.
Syntax
- PlayAnimation(string sequence,number speed=1.0f, number blendtime=500, number mode=0)
- PlayAnimation(number sequence,number speed = 1.0f,number blendtime = 500, number mode = 0)
Parameters
- sequence: the sequence name or index of the animation to be played.
- speed: the speed at which to play the animation.
- blendtime: the number of milliseconds it takes for the current animation to smoothly replace the previously played animation.
- mode: set to zero for looping animation or one for one-shot animation. When one-shot animation mode is used, the script or actor function EndAnimation() will be called when the sequence is completed, passing the sequence number in as an argument.
Example
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,0.75,-2)
light = DirectionalLight:Create()
light:SetRotation(35,35,0)
--Load a model
model = Model:Load("Models/Characters/Crawler/crawler.mdl")
--Play an animation
model:PlayAnimation("Run",0.05)
while true do
if window:Closed() or window:KeyHit(Key.Escape) then break end
Time:Update()
world:Update()
world:Render()
context:Sync()
end