|
| 16 Jun 2014 04:38 PM |
How do I set a model's CFrame based off another part? Such as modify this line into one that would work for a model;
part1.CFrame = part2.CFrame * CFrame.new()
Thanks in advance |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 04:45 PM |
wazap i know youre there you too cntkillme |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Jun 2014 04:51 PM |
It's my last day for a month or so, but use objectspace
part1.CFrame = CFrame.new() * part1.CFrame:toObjectSpace(part2.CFrame) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 04:53 PM |
oki ill miss your help ;-;
But just to be sure, inside CFrame.new() is where I offset it and such, right? Just checking |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 16 Jun 2014 04:53 PM |
function translatemodelbyobjectspace(model,modelcfn,cfn,offset) local tab = model:children() for I =1,#tab do if tab[I]:IsA'BasePart' then tab[I].CFrame = cfn:toWorldSpace(modelcfn:toObjectSpace(tab[I].CFrame)*offset) end end end
translatemodelbyobjectspace(workspace.Model,workspace.Model:GetModelCFrame,workspace.Part.CFrame,CFrame.new(10,0,0)) |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 16 Jun 2014 04:57 PM |
Wrote this a few days ago, so I have it handy: http://pastebin.com/un5eNnr0
Usage:
CFrameModel(model,newposition,rotation)
|
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Jun 2014 05:09 PM |
Wait none of yours worked the way I needed @cntkillme, I need a model based off of a part @Bebee, yours didnt do anything at all @RoflBread, yours did what TranslateBy() does |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Jun 2014 05:53 PM |
Just change part1 to the other one and multiply the whole thing? Bebe's might work, but 'workspace.Model:GetModelCFrame()' |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 16 Jun 2014 06:54 PM |
@Sensei, it's doable with mine, just not conveniently (or efficiently, before anyone says)
(Assuming part1 and part2 are models)
part1.CFrame = part2.CFrame * CF
becomes
CFrameModel(part1, (part2.CFrame * CF).p, part2.CFrame-part2.Position) |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 16 Jun 2014 06:57 PM |
or rather part2 being a part.
Bleh. idk. I could adapt my function for what you want tomorrow, but w/e I'm off now. |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 06:59 PM |
| I need a model to have a cframe based off of a part. Such as a model filled with about 50 parts be offsetted from a character's torso. |
|
|
| Report Abuse |
|
|