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

How to take into account orientation of part when rotating part around a center?

Asked by 6 years ago

I have a script that rotates the top half of a sphere around to the bottom half of it keeping the center the same.

What I am having trouble with is if I rotate the whole model the rotation takes place around the global axis, not the local axis like I would like it to.

I have tried playing around with COS and SIN using the parts Orientation in the CFrame.Angles but no combination I tried worked. I later read that using EularAngles only works with global axis. Is there a way to translate this to the local axis using a lookVector or part Orientation or some other function?


TopPart = game.Workspace.TopPart Center = game.Workspace.Center Tpos = TopPart.Position Cpos = Center.Position for i=1,180 do TopPart.CFrame = CFrame.new(Center) * CFrame.Angles(-math.rad(i),0,0) * CFrame.new(0,Tpos.Y - Cpos.Y,0) wait(0.005) end
0
try putting `CFrame.Angles()` at the end of the expression. creeperhunter76 554 — 6y
0
I'm pretty sure you should use Heartbeat, as that fires after physics, but I'm not sure. https://forum.scriptinghelpers.org/topic/56/how-tasks-and-threading-works-in-roblox-pictures hiimgoodpack 2009 — 6y
0
You could use the bottom part's CFrame as a starting point, something like TopPart.CFrame = BottomPart.CFrame * CFrame.new(0, BottomPart.Size.Y/2, 0) * CFrame.Angles(angle, 0, 0) * CFrame.new(0, TopPart.Size.Y/z, 0) nicemike40 486 — 6y

Answer this question