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: Model CFrame

Previous Thread :: Next Thread 
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
16 Jun 2014 04:45 PM
wazap i know youre there
you too cntkillme
Report Abuse
cntkillme is not online. 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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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 is not online. 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 is not online. 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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
16 Jun 2014 04:59 PM
ty guys
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
16 Jun 2014 05:18 PM
bump
Report Abuse
cntkillme is not online. 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 is not online. 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 is not online. 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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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
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