generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Model rotation

Previous Thread :: Next Thread 
janthran is not online. 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
DonnyTheDemented is not online. DonnyTheDemented
Joined: 29 May 2010
Total Posts: 1413
12 Sep 2013 08:39 PM
No, no matter what tool you use. The loop is there in some manner.
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
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 is not online. 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 is not online. 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
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
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 is not online. 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
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
14 Sep 2013 12:25 AM
You have to call it on a "Model" object.
Not a boolvalue.
Report Abuse
janthran is not online. 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 is not online. 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
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. janthran
Joined: 15 May 2009
Total Posts: 17429
14 Sep 2013 01:18 AM
doesn't seem like it :/
help?
Report Abuse
janthran is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image