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

How to rotate a group of floating, anchored bricks, on a center axis?

Asked by 9 years ago

I'm using corner wedges to form a diamond that is floating in the air. I need the diamond to rotate around it's middle. How do I go about doing this? I can rotate them individually but I can't have them float and not be anchored at the same time.

0
It sounds like you need to un-anchor the bricks and weld them together. RedCombee 585 — 9y
0
You don't need to, though that would also be a solution BlueTaslem 18071 — 9y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

You can accomplish this with welds by unanchoring all them, welding them together, and welding some other anchored object to one of the parts (e.g., the baseplate).


Instead, if you want to use CFrame, you can fairly easily do this using cframe:toObjectSpace(cframe) and cframe:toWorldSpace(cframe):

-- Twists all parts in `model` angle `angle` (in radians) about the Y axis
function twist(model, angle)
    local origin = CFrame.new();
    local out = origin * CFrame.Angles(0, angle, 0);
    for _, part in pairs(model:GetChildren()) do
        if part:IsA("BasePart") then
            part.CFrame = out:toWorldSpace(
                origin:toObjectSpace(part.CFrame)
            );
        end
    end
end

For example, to make it spin, you could use

while true do
    wait();
    twist(workspace.Model, 0.1)
end
0
Problem is I wasn't sure how to weld an anchored part to them. I tried using something I found on the wiki "WeldBetween" but that didn't work. Jammintoad 0 — 9y
0
Ok I'm getting somewhere, but some parts are spazzing out for no reason Jammintoad 0 — 9y
0
oMG I think I got it to work thanks so much man! Jammintoad 0 — 9y
0
Now the bricks are spazzing out a little bit, if you look close. what'd id o wrong q *only happens in online games Jammintoad 0 — 9y
Ad

Answer this question