wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 15 Sep 2013 04:33 PM |
function rotate(cen, obj) arr = obj:GetChildren() obj:BreakJoints() for p, l in ipairs(arr) do if l:IsA("Part") or l:IsA("Wedge") or l:IsA("CornerWedge") or l:IsA("Truss") then local posi = l.Position-Vector3.new(cen.X, cen.Y, cen.Z) l.CFrame = CFrame.new(cen.p+Vector3.new(-posi.Z, posi.Y, posi.X))*CFrame.Angles(math.rad(l.Rotation.X), math.rad(l.Rotation.Y)+math.pi/2, math.rad(l.Rotation.Z)) end end obj:MakeJoints() end
Basically what this does is rotates an entire model... Its almost equivalent to ctrl+r on a model in Studio... except that its not, and I'm trying to.
This only works if the parts in the model all have a rotation of 0 for X and Z. How would I make it so that it would rotate 90 degrees about the Y axis no matter what rotation X and Z are? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 04:35 PM |
| so you just want to rotate a model basically? i have a script for that ill post in a bit. |
|
|
| Report Abuse |
|
|
magnalite
|
  |
| Joined: 18 Oct 2009 |
| Total Posts: 2467 |
|
|
| 15 Sep 2013 04:35 PM |
| If you know how to use quaternions (unlikely since they are super advanced) I would recommend using them. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 15 Sep 2013 04:39 PM |
Well I didnt know about quaternions. Now I do. And its relatively easy to understand actually... thanks :D
And ya I'm trying to rotate a model basically... It'll be helpful if you could still post it, I could use it as a reference.. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2013 04:43 PM |
function TransformModel(objects, center, new, recurse) for _,object in pairs(objects) do if object:IsA("Part") then object.CFrame = new:toWorldSpace(center:toObjectSpace(object.CFrame)) end if recurse then TransformModel(object:GetChildren(), center, new, true) end end end
while true do local center = script.Parent.Parent:GetModelCFrame() TransformModel( script.Parent:GetChildren(), center, center * CFrame.Angles(0,math.rad(1),0), true ) wait(0.05) end
--Change the second half to your specifications and pathways. you might want to take of the while true do loop if you dont want a constant rotation,, you probably know that math.rad(1) is 1degree. i didnt write this script. but i used it for my revolving door :P |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 15 Sep 2013 04:46 PM |
*flips table* center*CFrame.Angles(). Of course... stupid me -_-
Thanks though :D |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 15 Sep 2013 05:04 PM |
| Quaterions didnt work in this case... I encounter the same problem. I pretty used the 2nd script. It worked beautifully. |
|
|
| Report Abuse |
|
|