janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 12 Sep 2013 08:33 PM |
| Can you rotate a model without using that intimidating looking for loop? |
|
|
| Report Abuse |
|
|
|
| 12 Sep 2013 08:39 PM |
| No, no matter what tool you use. The loop is there in some manner. |
|
|
| Report Abuse |
|
|
|
| 12 Sep 2013 09:13 PM |
What DonnyTheDemented said is 99% true. It is completely possible though to do it without a loop, it is just average of 50 times longer then with a loop. For example, with and without a loop:
parts = {"Part1",Part2"} model = game.Workspace.Model
for i,v in pairs(parts) do model[v].CFrame = CFrame(0,math.random(5),math.random(5)) end
other way:
game.Workspace.Model.Part1.CFrame = CFrame.new(0,math.random(5),math.random(5)) game,Workspace.Model.Part2.CFrame = CFrame.new(0,math.random(5),math.random(5))
not the best example, but you can see how quickly the second script would be alot more typing to add more parts, then the first script, which you just have to add a string name |
|
|
| Report Abuse |
|
|
form2275
|
  |
| Joined: 09 Jul 2007 |
| Total Posts: 6041 |
|
|
| 12 Sep 2013 11:36 PM |
Create a part in the center of the model, then set it as the PrimaryPart. Rotate that part Set the Model's Parent to nil, use the MoveTo() function to reset the model's position. Bring tha model back to the Workspace. |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 12:15 AM |
@Jetta: The problem I have is that my models all have models in them.
@Form: I don't understand exactly, can anyone elaborate? |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2013 12:19 AM |
This should work...........
function rotateModel(Model,CF) local Center = Model:GetModelCFrame() for _,n in pairs(Model:GetChildren()) do if n:IsA("BasePart") then n.CFrame = (CF*Center):toWorldSpace(Center:toObjectSpace(n.CFrame)) end rotateModel(n,CF) end end
rotateModel(Workspace.Thing,CFrame.new(0,math.rad(90),0)) |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 12:23 AM |
| I think it's missing an "if" statement because it errored at "GetModelCFrame is not a valid member of boolvalue" |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2013 12:25 AM |
You have to call it on a "Model" object. Not a boolvalue. |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 12:28 AM |
The model has a boolvalue in it. So there needs to be a line somewhere that does IsA:("Model") or something.. Right? |
|
|
| Report Abuse |
|
|
Xeptix
|
  |
| Joined: 14 Mar 2013 |
| Total Posts: 1115 |
|
|
| 14 Sep 2013 12:33 AM |
function rotateModel(Model,CF) local Center = Model:GetModelCFrame() for _,n in pairs(Model:GetChildren()) do if n:IsA("BasePart") then n.CFrame = (CF*Center):toWorldSpace(Center:toObjectSpace(n.CFrame)) elseif n:IsA("Modle") then -- yeah.......... forgot that.... rotateModel(n,CF) end end end |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2013 12:35 AM |
^ Nah...
I fixed that error but it does not seem to rotate.
Just use this...It should work
--Credits to Anaminus (http://www.roblox.com/Forum/ShowPost.aspx?PostID=54219761)
function TransformModel(objects, center, new, recurse) for _,object in pairs(objects) do if object:IsA("BasePart") then object.CFrame = new:toWorldSpace(center:toObjectSpace(object.CFrame)) end if recurse then TransformModel(object:GetChildren(), center, new, true) end end end
Example:
-- rotate entire model by 45 degrees local center = model:GetModelCFrame() TransformModel( model:GetChildren(), center, center * CFrame.Angles(0,math.rad(45),0), true ) |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 14 Sep 2013 12:38 AM |
How to rotate everything in a model: http://www.roblox.com/Forum/ShowPost.aspx?PostID=106696156 Last post. |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 12:46 AM |
| why isn't there just a Model:Rotate() method? qq |
|
|
| Report Abuse |
|
|
form2275
|
  |
| Joined: 09 Jul 2007 |
| Total Posts: 6041 |
|
|
| 14 Sep 2013 12:54 AM |
ResetOrientationToIdentity()
Rotates all parts in the model to the orientation that was set using SetIdentityOrientation(). If this function has never been called, rotation is reset to GetModelCFrame()'s rotation. |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 12:56 AM |
| Would that rotate a whole model, or just position all of the parts in it awkwardly, like make my walls point outward |
|
|
| Report Abuse |
|
|
form2275
|
  |
| Joined: 09 Jul 2007 |
| Total Posts: 6041 |
|
|
| 14 Sep 2013 12:58 AM |
>>janthran I've never used this function, I just remembered seeing it once so I went back to find it. I assume it tries to maintain the model's original image. |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 01:15 AM |
so like House:SetIdentityOrientation(0,math.pi/2,0) House:ResetOrientationToIdentity()
would that work? |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 01:18 AM |
doesn't seem like it :/ help? |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 14 Sep 2013 01:26 AM |
| Okay so the Anaminus one works except I want the model to stay in the same position. How do I do that? |
|
|
| Report Abuse |
|
|