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 » Scripters
Home Search
 

Re: rotating models

Previous Thread :: Next Thread 
Aperturee is not online. 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
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
16 Sep 2015 09:21 AM
How do you not know how to do such thing
Report Abuse
CaptainGector is not online. CaptainGector
Joined: 02 May 2014
Total Posts: 487
16 Sep 2015 09:22 AM
CFrames! Very math.
Report Abuse
prepareds is not online. 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
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
16 Sep 2015 10:59 AM
Weld them to the "Core" and add a BodyAngularVelocity to the main brick. np
Report Abuse
Aperturee is not online. 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 is not online. Aperturee
Joined: 22 Jan 2013
Total Posts: 306
16 Sep 2015 11:33 AM
Bump, someone help.
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
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 is not online. 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 is not online. 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 is not online. 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
EradicateTheNoobs is not online. EradicateTheNoobs
Joined: 03 Feb 2012
Total Posts: 1314
28 Sep 2015 02:00 AM
Or you can just set a primary part and rotate it with cframe.angles
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
28 Sep 2015 07:48 AM
Sorry, try replacing "for i,v in pairs(model)" "model" to model:GetChildren()
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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