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: CFrame Rotation of a Model

Previous Thread :: Next Thread 
TheNickmaster21 is not online. TheNickmaster21
Joined: 04 Oct 2008
Total Posts: 9490
07 Apr 2014 08:57 PM
Okay, so for my script, I create a base part along with all the detail parts around it. This base part is used for the central position of the model and its rotation. There are template models that have a base part and preCFramed parts around that Base. So far, I have been able to correctly position all the parts around the base part. However, I am unable to take the CFrame of the new Base part into account with my current script, help!

What I currently have:
function AdjustPosition(Model, Type) --Root Part Called Base
for i, v in pairs(Model:GetChildren()) do
if( v.Name ~= "Base" and v:IsA("Part") )then
v.CFrame = ( Templates[Type][v.Name].CFrame - Templates[Type].Base.Position) + Model.Base.Position
end
end
end

To clarify what I am trying to do: I have a template model with the ideal configuration. I want to be able to use a rotated and moved Base part and get the CFrames of the other parts using the different from the new Base CFrame and the Template Base CFrame...
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
07 Apr 2014 08:58 PM
Hush...


http://wiki.roblox.com/index.php/User_talk:NXTBoy/Scripts/Model_CFrame
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Apr 2014 09:01 PM
I'll make a universal CFrame right here on the spot (not tested of course)

local function setModelCFrame(model, newCFrame)
origin = model.PrimaryPart.CFrame or model:GetModelCFrame()

local parts = {}
local function recurse(obj) --inefficient recursion yey
for index, value in next, obj:GetChildren() do
if value:IsA("BasePart") and value ~= model.PrimaryPart then table.insert(parts, value) end
recurse(value) --yey inefficiency
end
end
recurse(model)

for index, value in next, parts do
value.CFrame = origin:toObjectSpace(value.CFrame) * newCFrame)
end
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Apr 2014 09:03 PM
Damnit, beat me to it
Report Abuse
TheNickmaster21 is not online. TheNickmaster21
Joined: 04 Oct 2008
Total Posts: 9490
07 Apr 2014 09:08 PM
@Bebee

I've seen that script all over the place. I just don't know how to modify that to fit what I need it to do...

@cntkillme

Uh, I'll try adapting that to work with my stuff.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Apr 2014 09:10 PM
You should probably do local origin =
Report Abuse
TheNickmaster21 is not online. TheNickmaster21
Joined: 04 Oct 2008
Total Posts: 9490
07 Apr 2014 09:11 PM
@cnt

i.imgur/yI12rnZ
Report Abuse
TheNickmaster21 is not online. TheNickmaster21
Joined: 04 Oct 2008
Total Posts: 9490
07 Apr 2014 09:20 PM
Simple Version = I want to rotate this CFrame (( Templates[Type][v.Name].CFrame - Templates[Type].Base.Position) + Model.Base.Position) by the rotation of the Model.Base.Rotation or whatever. How do?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Apr 2014 09:22 PM
value.CFrame = value:toObjectSpace(origin.CFrame) * newCFrame

Try that I guess

But if you want to use the rotation property, why not Lerp it?
Report Abuse
TheNickmaster21 is not online. TheNickmaster21
Joined: 04 Oct 2008
Total Posts: 9490
07 Apr 2014 09:25 PM
Dufudge is Lerp?
Report Abuse
TheNickmaster21 is not online. TheNickmaster21
Joined: 04 Oct 2008
Total Posts: 9490
07 Apr 2014 09:26 PM
Nuuuuuuuuuuuuuuuu, stop with the value origin garbage :P I have no idea how that translates to my code. Could you PLEASE use my variables/equations so I'm less confused?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
07 Apr 2014 09:45 PM
origin is original part

the Root part

right?
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