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

How to Rotate Around a Point?

Asked by 8 years ago

I have scoured the wikis far and wide. I have viewed the YouTube videos, but with no results. The question: How do I rotate an object around a certain point instead of its center? Sorry if this seems lazy, but trust me I have searched. ~yoman1776

2 answers

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

Utilize Object Space!

Here's an example:

local Center = CFrame.new(12, 165, 124)
local Part = workspace.Part
local i = 0
while true do
    Part.CFrame = Center:toWorldSpace(
        CFrame.new(
            Vector3.new(
                math.cos(math.rad(i)),
                0,
                math.sin(math.rad(i))
            )*10,
            Center.p
        )
    )
    --The syntax for this is <BASECFrame>:toWorldSpace(<CFrame in BASECFrame's Object Space>)
    --The inverse is then <BASECFrame>:toObjectSpace(<CFrame in World Space to Convert to BASECFrame's Object Space>)
    --I.e. Center:toObjectSpace(Part.CFrame)
    i = (i + 1)%360
end

Obviously, the math for this is harder if you want to rotate around an arbitrary axis, but the gist of it is there.

Ad
Log in to vote
0
Answered by 8 years ago

http://wiki.roblox.com/index.php?title=Joint <- Scroll to the bottom, there should be a few examples

Basically you make a hinge, set the two parts, and edit the C0 and C1 properties, dont ask me how to set the C1 and C0 properties, I haven't found an easy way to do it

Answer this question