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: CFraming in relation

Previous Thread :: Next Thread 
Firebrand1 is online. Firebrand1
Joined: 12 Feb 2009
Total Posts: 2692
22 Apr 2015 03:17 PM
I want to be able to move/rotate a central part and have the rest of the model move respectively to that part. The math behind it is a little above my head. Can anyone help me through it or paste a bit of code that does the trick?
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
22 Apr 2015 03:22 PM
Example for making a part 10 studs above another part.

part = workspace.Part

part2 = Instance.new("Part", workspace)
part2.Anchored = true
part2.CFrame = part.CFrame * CFrame.new(0, 10, 0)

You take the original part's CFrame and add (technically multiply) another CFrame to it.
Report Abuse
Firebrand1 is online. Firebrand1
Joined: 12 Feb 2009
Total Posts: 2692
22 Apr 2015 03:29 PM
Thanks, but that's not quite what I was asking. Part1 and Part2 already exist.

I want to move Part1, and then I want Part2 to move so it is exactly where it was in relation to Part1, whether Part1 slides 1 stud or does a barrel roll and ends with some weird rotation.
Report Abuse
Firebrand1 is online. Firebrand1
Joined: 12 Feb 2009
Total Posts: 2692
22 Apr 2015 04:29 PM
Bump
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
22 Apr 2015 04:30 PM
Perhaps you want welds then

Report Abuse
Funse is not online. Funse
Joined: 11 Jun 2012
Total Posts: 7887
22 Apr 2015 04:30 PM
PrimaryPart :/
Report Abuse
Firebrand1 is online. Firebrand1
Joined: 12 Feb 2009
Total Posts: 2692
22 Apr 2015 04:34 PM
Oh, wow, there is some PrimaryPart API that works perfectly for that. I don't think that was there when I first saw learned about PrimaryPart. I will give it a try, thanks.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
22 Apr 2015 04:48 PM
You'd do:

local Part1 = workspace.Part1
local Part2 = workspace.Part2

local RelativeCFrame = Part2.CFrame:toObjectSpace(Part1.CFrame);

-- move part 1
Part1.CFrame = CFrame.new(1,5,1) * CFrame.Angles(1,0,-.8);

-- Adjust part 2 to be in the same relative orientation
Part2.CFrame = RelativeCFrame:toWorldSpace(Part1.CFrame);
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