Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I create a pivot point to rotate a part around?

Asked by
AZDev 590 Moderation Voter
7 years ago
Edited 7 years ago

I know that Workspace.B.CFrame = workspace.A.CFrame * CFrame.new((workspace.Part.Size.X/2+workspace.B.Size.X/2), 0, 0) will offset the part so that part B is right beside part A.

What I want to do is rotate the part around that point. So basically, act as though there is a joint in between the two parts and rotate around it. It would also be useful to know how to change the offset of said 'joint' so that the pivot point is set to the top edge of part.

I did try Workspace.B.CFrame = workspace.Part.CFrame * CFrame.new((workspace.Part.Size.X/2+workspace.B.Size.X/2), 0, 0) * CFrame.Angles(0, 0, math.rad(45)).

This didn't work the way I though it would. The rotation is obviously going to vary and will probably be on all axes.

Math isn't my strong suite so thanks a lot for the help.

1 answer

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago

Hi, AZDev, friend.

What I would do is use PrimaryPart to make a model pivit. You can do this either manually or with a script.

With a script, it would look like this:

local MODEL = workspace.MODEL
MODEL.PrimaryPart = MODLE.Main -- "Main" would be the part to pivit around.

Or, set it manually:

-- Just click on the model a open the Properies tab and you should see "PrimaryPart". Click on PrimaryPart, hen select the pivit part, which would be "Main" like in the script.

Now, once you set the PrimaryPart, you may now use CFrame.Angles()

local MODEL = workspace.MODEL
MODEL:SetPrimaryPartCFrame(MODEL:GetPrimaryPartCFrame() * CFrame.Angles(0,0,math.rad(45)))

If this helped, please be sure to accept :)

0
While this is a good suggestion it won't work for me. I know it is possible to set a pivot point using math. Thanks anyway though. AZDev 590 — 7y
0
Np. FiredDusk 1466 — 7y
Ad

Answer this question