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
 

Re: Ummmm really hard math/CFrame question.....

Previous Thread :: Next Thread 
wazap is not online. 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
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
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 is not online. 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 is not online. 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
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
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 is not online. 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 is not online. 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
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