|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 22 Apr 2015 04:30 PM |
Perhaps you want welds then
|
|
|
| Report Abuse |
|
|
Funse
|
  |
| Joined: 11 Jun 2012 |
| Total Posts: 7887 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|