|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 Apr 2014 09:10 PM |
| You should probably do local origin = |
|
|
| Report Abuse |
|
|
| |
|
|
| 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
|
  |
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 07 Apr 2014 09:45 PM |
origin is original part
the Root part
right? |
|
|
| Report Abuse |
|
|