Aperturee
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 306 |
|
|
| 16 Sep 2015 09:16 AM |
| How do I rotate a whole model by its middle axis, I don't want the bricks to rotate individually, I want them all to rotate together, keeping the model's original look. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 09:21 AM |
| How do you not know how to do such thing |
|
|
| Report Abuse |
|
|
| |
|
prepareds
|
  |
| Joined: 07 Sep 2015 |
| Total Posts: 182 |
|
|
| 16 Sep 2015 10:56 AM |
| Honestly, I've never learned, but I probably should.. I should be way ahead of this part by now. Free bump. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2015 10:59 AM |
| Weld them to the "Core" and add a BodyAngularVelocity to the main brick. np |
|
|
| Report Abuse |
|
|
Aperturee
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 306 |
|
|
| 16 Sep 2015 11:13 AM |
| I don't have to do it via studio, but via script. You know, instead of asking me how I don't know this, you could actually tell me. :] |
|
|
| Report Abuse |
|
|
Aperturee
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 306 |
|
| |
|
|
| 16 Sep 2015 11:39 AM |
local model = whateverTheModelIs -- If the model has a primaryPart it'll be counted as core, else a random brick will be chosen.
local Core if model.PrimaryPart and model.PrimaryPart.Parent then Core = model.PrimaryPart else repeat wait() Core = (model:GetChildren())[math.random(1,#model:GetChildren())] until Core end
for i,v in pairs(model) do if v ~= Core then local weld = Instance.new("Weld", v) weld.C0 = Core.CFrame:inverse() weld.C1 = v.CFrame:inverse() weld.C0 = Core weld.C1 = v end end
local angVelocity = Instance.new("BodyAngularVelocity", Core) angVelocity.MaxThrust = math.huge angVelocity.Velocity = whatever.. |
|
|
| Report Abuse |
|
|
Ice7
|
  |
| Joined: 26 Jun 2007 |
| Total Posts: 1058 |
|
|
| 16 Sep 2015 12:33 PM |
local Part = script.Parent local center = CFrame.new(Part.Position) --Can be offset to shift rotation axis
while wait() do Part.CFrame = (center * CFrame.Angles(0,0.1,0)) * (center:inverse() * Part.CFrame) end
Notice how you're multiply a cframe that contaians "center" with another cframe that contains its inverse. It causes the position of the brick to remained unchanged. |
|
|
| Report Abuse |
|
|
Ice7
|
  |
| Joined: 26 Jun 2007 |
| Total Posts: 1058 |
|
|
| 16 Sep 2015 12:36 PM |
Oh, and if you want to rotate an entire model you use the same approach, just define the center CFrame using the :GetModelCFrame() function, but the math is the same. For example
local M = workspace.Model local ModelCenter = M:GetModelCFrame() for _,v in pairs(M:GetChildren()) do
if(v:isA('BasePart')) then v.CFrame = (ModelCenter * CFrame.Angles(0,math.pi/4,0)) * (ModelCenter:inverse() * v.CFrame) end
end |
|
|
| Report Abuse |
|
|
Aperturee
|
  |
| Joined: 22 Jan 2013 |
| Total Posts: 306 |
|
|
| 28 Sep 2015 01:24 AM |
| Workspace.Model.Script:13: bad argument #1 to 'pairs' (table expected, got Object) |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2015 02:00 AM |
| Or you can just set a primary part and rotate it with cframe.angles |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2015 07:48 AM |
| Sorry, try replacing "for i,v in pairs(model)" "model" to model:GetChildren() |
|
|
| Report Abuse |
|
|