@tlr22 finally done
local function RotateAroundPivotNew(Hinge: CFrame, ConnectFrom: string, alpha: number): CFrame
ConnectFrom = string.lower(ConnectFrom)
alpha = math.clamp(alpha, 0, 1)
local PivotFromTop = if string.sub(ConnectFrom, 1, 1) == "t" then 1 else -1
local PivotSide, PivotSideX, PivotSideZ = string.sub(ConnectFrom, 2), 0, -40
local RotX, RotZ = math.rad(alpha * 90) * PivotFromTop, 0
if PivotSide == "left" then
PivotSideX = PivotSideZ PivotSideZ = 0
RotZ = -RotX RotX = 0
elseif PivotSide == "right" then
PivotSideX = -PivotSideZ PivotSideZ = 0
RotZ = RotX RotX = 0
elseif PivotSide == "back" then
PivotSideZ *= -1 RotX *= -1
end
return Hinge * CFrame.new(PivotSideX, 0.5 * PivotFromTop, PivotSideZ)
* CFrame.Angles(RotX, 0, RotZ) * CFrame.new(PivotSideX, 0.5 * -PivotFromTop, PivotSideZ)
end
i’ll be using this function to get where each face/side/wall of the cube should be, to explain how it works/my thought process; each face of the cube will be pivoting as if a door along an anchored hinge, and the alpha parameter is for how far into the “tween” its gotten. for example, with an alpha value of 0.5 and “TFront” as the ConnectFrom parameter to signify which edge of the cube it will pivot around, it will return a CFrame that can be given back to the cube face, where its rotated halfway on the top-front edge of the “hinging” part.
(looking at this screenshot made me realise i practically just remade the Archimedes plugin but wtv lol)
(this is the line i was using to apply the cframe to these two test parts)
workspace.TestDoor.CFrame = RotateAroundPivotNew(workspace.TestHinge.CFrame, "TFront", .5)
for anyone who may use my function, the size of each cube face is hardcoded into the function based on my cube im using so i dont really see a use of adding a parameter/global variable to change the final calculation, so like you said, i’ll be using TweenService:GetValue() and basically just plugging that in for the alpha value of each cube face and that should be it
my main slight worry is the last line where im calculating the final CFrame and how im multiplying 4 CFrames in each function call for (at most) 5 cube faces every frame, so will this be a resource intensive process? is there some redundancies in my CFrame calculation that i can remove to optimise the function? and should I run this “tween” on the server, or fire out to all clients to make them do the process clientside if it would noticeably make it look smoother?