of     1   

Conmiro
#140988429Sunday, July 20, 2014 10:15 PM GMT

So...I've been messing around with this for...months on/off and I still can't figure out how to create a simple transitional animation for rotating a model...I have come to the following script as a result which looks quite hideous and I'm wondering if there is any way to make a shorter/more efficient version? Feel free to copy and run the script to see what I'm trying to accomplish. It works. But, it's hideous. And I do want to know if there is a better/more efficient way. Script Starts Below [ The following script was pulled from a trash can, but works ] ======================================================================= model = script.Parent mainPart = model.MainPart function rotateBy(model, center, rot, origin) for _, p in pairs(model:children()) do if p:IsA("BasePart") then p.CFrame = origin[p] end end for _,object in pairs(model:children()) do if object:IsA("BasePart") then object.CFrame = rot:toWorldSpace(center:toObjectSpace(object.CFrame)) end rotateBy(object, center, rot) end end function timeBy(model, mainPart, rot) cframe = mainPart.CFrame origin = {} for _, turn1 in pairs(model:children()) do if turn1:IsA("BasePart") then origin[turn1] = turn1.CFrame end end x = 0 y = 0 z = 0 x1 = false y1 = false z1 = false if rot.X < 0 then x1 = true end if rot.Y < 0 then y1 = true end if rot.Z < 0 then z1 = true end for i = 0, math.abs(rot.X+rot.Y+rot.Z) do print(i) wait() x = x1 and -i or i y = y1 and -i or i z = z1 and -i or i abx = math.abs(x) aby = math.abs(y) abz = math.abs(z) last = false if abx >= math.abs(rot.X) and aby >= math.abs(rot.Y) and abz >= math.abs(rot.Z) then last = true end if abx >= math.abs(rot.X) then x = rot.X end if aby >= math.abs(rot.Y) then y = rot.Y end if abz >= math.abs(rot.Z) then z = rot.Z end if last then x = rot.X y = rot.Y z = rot.Z end rotateBy(model, cframe, cframe * CFrame.Angles(math.rad(x),math.rad(y),math.rad(z)), origin) print(x,y,z) end end timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0)) =======================================================================
Conmiro
#140989935Sunday, July 20, 2014 10:32 PM GMT

bump
Raphael7
#140990600Sunday, July 20, 2014 10:39 PM GMT

What you could do is put a BodyGyro and a BodyPosition in the model (specifically the torso or the head). Now set the BodyPosition; it should be straight forward. Then the BodyGyro; this is where the scripting starts. torso = location while true do wait() bg = location bg.cframe = torso.CFrame * CFrame.new(0, 0.01, 0) end
Conmiro
#141196754Tuesday, July 22, 2014 8:52 PM GMT

The problem is, not only is the model not anchored, but the parts are not welded/jointed together. I was trying to create a smooth rotation for an entire model.
Raphael7
#141203999Tuesday, July 22, 2014 10:01 PM GMT

Weld them together, and you should have no problem.
Conmiro
#141211521Tuesday, July 22, 2014 11:15 PM GMT

Welds don't work with anchored parts. Unanchoring them momentarily then anchoring them really fast breaks some stuff in my other scripts..
BothAngles
#141211758Tuesday, July 22, 2014 11:17 PM GMT

model = script.Parent mainPart = model.MainPart function rotateBy(model, center, rot, origin) for _, p in pairs(model:children()) do if p:IsA("BasePart") then p.CFrame = origin[p] end end for _,object in pairs(model:children()) do if object:IsA("BasePart") then object.CFrame = rot:toWorldSpace(center:toObjectSpace(object.CFrame)) end rotateBy(object, center, rot);Spawn(wait) end end function timeBy(model, mainPart, rot) cframe = mainPart.CFrame origin = {} for _, turn1 in pairs(model:children()) do if turn1:IsA("BasePart") then origin[turn1] = turn1.CFrame end end x = 0 y = 0 z = 0 x1 = false y1 = false z1 = false if rot.X < 0 then x1 = true end if rot.Y < 0 then y1 = true end if rot.Z < 0 then z1 = true end for i = 0, math.abs(rot.X+rot.Y+rot.Z) do print(i) wait() x = x1 and -i or i y = y1 and -i or i z = z1 and -i or i abx = math.abs(x) aby = math.abs(y) abz = math.abs(z) last = false if abx >= math.abs(rot.X) and aby >= math.abs(rot.Y) and abz >= math.abs(rot.Z) then last = true end if abx >= math.abs(rot.X) then x = rot.X end if aby >= math.abs(rot.Y) then y = rot.Y end if abz >= math.abs(rot.Z) then z = rot.Z end if last then x = rot.X y = rot.Y z = rot.Z end rotateBy(model, cframe, cframe * CFrame.Angles(math.rad(x),math.rad(y),math.rad(z)), origin) print(x,y,z) end end timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0)) wait(2) timeBy(model, mainPart, Vector3.new(0,90,0))
Conmiro
#141212791Tuesday, July 22, 2014 11:27 PM GMT

What exactly did you change..?
Raphael7
#141238800Wednesday, July 23, 2014 3:58 AM GMT

Not exactly, I'm experienced in welding and have done some manual animations (which takes a long time). This is a script I made, put this in the model. Make sure the model is anchored just in case. target = script.Parent.Torso -- Change if needed for _, v in pairs(chest:GetChildren()) do pcall(function() v.Anchored = false v.CanCollide = false local cframe = CFrame.new(target.Position) local weld = Instance.new("Weld") weld.Part0 = target weld.Part1 = v weld.C0 = target.CFrame:inverse()*cframe weld.C1 = v.CFrame:inverse()*cframe weld.Parent = target end) end

    of     1