Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Looping an animation?

Asked by 10 years ago

I've got so many animation questions it's ridiculous, but hopefully someone here is partially qualified

So how do I loop an idle animation? If I export it as a looped animation then it won't ever let me change the animation from it to another one(for say, walking). I also want to loop the walking animation to make it less choppy instead of it firing over and over.

How do I just make the animations smooth like default animations? Are the default animations looped? What does priority do? Am I supposed to end looped animations to fire new ones?

local Humanoid = script.Parent.Humanoid

local animController = Instance.new('AnimationController')
animController.Parent = script.Parent

local Animations = {
    Walk = {id = 'rbxassetid://166955430'},
    Idle = {id = 'rbxassetid://166961426'},
}

local Animation = Instance.new("Animation")
function PlayAnim(Anim)
    Animation.AnimationId = Anim
    AnimTrack = Humanoid:LoadAnimation(Animation)
    AnimTrack:Play()
end

local Running
Humanoid.Running:connect(function(Speed)
    print(Speed)
    if Speed < 1 then
        Running = true
        PlayAnim(Animations.Idle.id)
    else
        Running = false
        PlayAnim(Animations.Walk.id)
    end
end)

while wait(30) do
    script.Parent.Humanoid:MoveTo(Vector3.new(math.random(-200,200),4,math.random(-200,200)),Game.Workspace.BasePlate)
end

1 answer

Log in to vote
1
Answered by
Usering 135
10 years ago

Manually looping an animation is hard to do and you can do it much easier and efficiently if it is set to looped when it is created.

Are the default animations looped? Yes, default animations are looped, but if you want it to look good, make sure the stop position is the same position and rotation in which they started.

What does priority do? Priority overwrites what needs to be overwritten in order for it to work in a certain circumstance. You can read more about it here

Ad

Answer this question