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

Help making running animation loop smoother?

Asked by 10 years ago

So, I'm making a custom running animation for the character. When the character runs, the script loops through a bunch of Vector3s. The problem is that the animation sometimes starts making the character's arms shake and that it isn't very smooth when restarting the loop. Could someone make my animation smoother?

Running Event (Assume everything is defined, database is a ModuleScript):

humanoid.Running:connect(function(speed)
    if speed > 0 then
        running = true
        while running do
            for frame = 1, #database.Frames.Running do
                for i = 0,1,0.1 do
                    for joint, start in pairs(database.Frames.Running[frame]) do
                        wait()
                        local lerp = (frame == #database.Frames.Running and Vector3.new(0,0,0) or start):Lerp(database.Frames.Running[frame+1] and database.Frames.Running[frame+1][joint] or Vector3.new(0,0,0),i)
                        character.Torso[joint].C0 = database.Humanoid[joint].C0*CFrame.new(lerp.X,lerp.Y,lerp.Z)
                    end
                end
            end
        end
    else
        running = false
        for i, joint in pairs(character.Torso:GetChildren()) do
            if joint:IsA("Motor6D") then
                character.Torso[joint.Name].C0 = database.Humanoid[joint.Name].C0
            end
        end
    end
end)

database ModuleScript:


database = {} database.Frames = {} database.Humanoid = {} --database.Humanoid --Motor6D database.Humanoid["Left Shoulder"] ={ C0 = CFrame.new(-1, 0.5, 0)*CFrame.Angles(-0,math.rad(-90),0), C1 = CFrame.new(0.5, 0.5, 0)*CFrame.Angles(-0,math.rad(-90),0) } database.Humanoid["Right Shoulder"] ={ C0 = CFrame.new(1, 0.5, 0)*CFrame.Angles(0,math.rad(90),0), C1 = CFrame.new(-0.5, 0.5, 0)*CFrame.Angles(0,math.rad(90),0) } database.Humanoid["Neck"] = { C0 = CFrame.new(0, 1, 0)*CFrame.Angles(math.rad(-90),0,math.rad(180)), C1 = CFrame.new(0, -0.5, 0)*CFrame.Angles(math.rad(-90),0,math.rad(180)) } database.Humanoid["Left Hip"] = { C0 = CFrame.new(-1, -1, 0)*CFrame.Angles(0,math.rad(-90),0), C1 = CFrame.new(-0.5, 1, 0)*CFrame.Angles(0,math.rad(-90),0) } database.Humanoid["Right Hip"] = { C0 = CFrame.new(1, -1, 0)*CFrame.Angles(0,math.rad(90),0), C1 = CFrame.new(0.5, 1, 0)*CFrame.Angles(0,math.rad(90),0) } --database.Frames --Running database.Frames.Running = {} database.Frames.Running = { { ["Right Shoulder"] = Vector3.new(0.1,-0.1,0), ["Left Shoulder"] = Vector3.new(0.1,-0.1,0) }; { ["Right Shoulder"] = Vector3.new(0,0,0), ["Left Shoulder"] = Vector3.new(0,0,0) }; { ["Right Shoulder"] = Vector3.new(-0.1,-0.1,0), ["Left Shoulder"] = Vector3.new(-0.1,-0.1,0) } } for animation, frames in pairs(database.Frames) do table.insert(frames,{}) for joint, _ in pairs(frames[1]) do frames[#frames][joint] = Vector3.new(0,0,0) end setmetatable(frames,{}) getmetatable(frames).__index = {Joints = {}} for joint, _ in pairs(frames[1]) do table.insert(frames.Joints,joint) end end return database
0
Do you have an active Place where I could see this in action? I don't understand what you mean by the arms shaking. adark 5487 — 10y
0
Hello? evolvedpikachu 40 — 10y

Answer this question