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

Upon setting the C0 of a Motor6D it weirdly jitters. Why does this happen?

Asked by
PolyyDev 214 Moderation Voter
5 years ago
Edited 5 years ago

My animation module:

do --// Animation
    local self = animate

    self.inprogress = false

    self.play = function(self,animdata)
        local cache = {}
        self.inprogress = true

        for frame,framedata in pairs(animdata) do
            if gun[framedata[1]] then
                local m = framedata[1]
                local endc = framedata[2]
                local d = framedata[3]
                local start = gun[m]

                for i = 0,1,0.1 do
                    local endc = framedata[2]
                    gun[m] = lerp(start,endc,i)
                    RunService.RenderStepped:wait()
                end
                if d then wait(d) end
            elseif framedata[1] == "weldmag" then
                local mw = gun.model.PrimaryPart.Mag

                cache.oldmagweld = mw
                mw.Parent = nil

                mw = Instance.new("Motor6D")
                mw.Part0 = gun.larm
                mw.Part1 = gun.model.Mag
                mw.Parent = cam
                mw.C0 = cf(0,0,-1.5)

                cache.newmagweld = mw
            elseif framedata[1] == "returnmag" then
                cache.oldmagweld.Parent = gun.model.PrimaryPart
                cache.newmagweld:Destroy()
            end
        end

        self.inprogress = true
    end
end

All the CFrames that go into the play function (in a ModuleScript):

local reload = function()
    local cam = workspace.CurrentCamera
    local ra = wfc(cam,"rightarm")
    local la = wfc(cam,"rightarm")
    local rw = wfc(cam,"rightarmweld")
    local lw = wfc(cam,"leftarmweld")

    return {
        {"janimcf0",cf(0,0.3,0)*ang(0,0,rad(-20))},
        {"lanimcf0",cf(-0.5,0.3,-0.5),0.1},
        {"weldmag","larm"},
        {"lanimcf0",cf(-0.5,2.5,-0.5),0.1},
        {"lanimcf0",cf(-0.5,0.3,-0.5),0.1},
        {"returnmag"},
        {"janimcf0",cf()},
        {"lanimcf0",cf()},
    }
end

How the Motor6D's get animated in a RenderStepped function

self.janimcf0 = cf(self.janimcf0p.p)*ang(self.janimcf0r.p.X,self.janimcf0r.p.Y,self.janimcf0r.p.Z)
self.lanimcf0 = cf(self.lanimcf0p.p)*ang(self.lanimcf0r.p.X,self.lanimcf0r.p.Y,self.lanimcf0r.p.Z)

self.joint.C0 = cf(1,-1.2,-0.3)
* self.janimcf0

self.ljoint.C0 = self.lc0
* self.lanimcf0

Everytime a new "frame" starts and ends it bounces forward, backwards, left, right, upwards or downwards. It is caused by the ljoint's C0 being set to lanimcf0

https://gyazo.com/946da6ca19f91bd1b385b98044db3fd7

I really don't know why this is happening. Here is a pastebin of the whole script if that would help

Answer this question