How do you make something rotate around a point thats not the center

i’m not sure on how to go about this. i’ve seen things involve trig. and i don’t understand trig enough for rotation. i only use it for angles. so if you have any ideas. please tell me

1 Like

My favorite non-mathematical solution is to make an invisible part that will serve as your hinge, add it to the model you want rotated around it, set it as the model’s PrimaryPart, and then just use :setPrimaryPartCFrame() on the model. If you rotate that invisible hinge, the whole model will revolve around it.

6 Likes

The example I am going to use is for a door.

You want a door to rotate around the hinge, rather than the centre otherwise it would just rotate on the spot. You are able to do this fairly easily with CFrames.

local Door = workspace.Door
local Hinge = workspace.Hinge

What you need now is an offset to get the door to rotate around. This offset is going to be the hinge’s CFrame.

local Offset = Hinge.CFrame:inverse() * Door.CFrame

Now, by rotating the hinge, you can apply the offset to the door:

local HingeStartCFrame = Hinge.CFrame
for i = 0,90 do
    Hinge.CFrame = HingeStartCFrame * CFrame.Angles(0,math.rad(i),0)
    Door.CFrame = Hinge.CFrame * Offset
    wait()
end

This code will rotate the door 90 degrees around the hinge. Hope this helps :slight_smile:

Important note, this will rotate the hinge as well. If you just want the ‘door’ part to rotate, change:

Hinge.CFrame = HingeStartCFrame * CFrame.Angles(0,math.rad(i),0)
Door.CFrame = Hinge.CFrame * Offset

to

NewCFrame = HingeStartCFrame * CFrame.Angles(0,math.rad(i),0)
Door.CFrame = NewCFrame  * Offset
9 Likes

Oooh, that’s a very smart idea . i’ll try that

interesting, I’ll try this too , thank you