SOLVED
Hello!
I am currently making a small personal game project which involves collecting food items. I am trying to make it so that the items rotate around on the world space Y-Axis instead of their object space. I have a diagram below to try and elaborate.
Here, I am trying to rotate my part around the black axis (World Space). However, I am unable to figure out a way to do this and most of my solutions result in rotation around the yellow axis (Object Space) or completely broken rotation altogether. My method of rotating the part involves connecting a function to the Heartbeat event that is meant to alter the part’s Y-Axis rotation in World Space by 1 degree every frame. Here is my code at the moment:
self._Maid.rotationConnection = game:GetService("RunService").Heartbeat:Connect(function()
self.model.CFrame = self.model.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(1), 0))
end)
This is my latest iteration of trying to solve this problem and it results in rotation around object space aka the yellow axis in the above diagram.
Any and all solutions would be appreciated but preferably ones that preserve my current method of updating the CFrame every frame instead of using - for example - Tween Service.
Update:
Solved the problem:
local RotCF = CFrame.Angles(0, math.rad(1) ,0):ToObjectSpace(self.model.CFrame)
self.model.CFrame = CFrame.fromMatrix(self.model.CFrame.Position,RotCF.XVector,RotCF.YVector,RotCF.ZVector)