local Part = game.Workspace.Part
game:GetService("RunService").RenderStepped:Connect(function()
local X, Y, Z = Part.CFrame:ToEulerAnglesXYZ()
local vX,vY,vZ = Part.Orientation.X, Part.Orientation.Y, Part.Orientation.Z
--print(Part.CFrame:ToEulerAnglesXYZ())
print(Part.Orientation)
Part.CFrame = CFrame.new(Part.CFrame.Position) * CFrame.Angles(0, math.rad(vY), 0)
end)
In CFrame
local Part = game.Workspace.Part
game:GetService("RunService").RenderStepped:Connect(function()
local X, Y, Z = Part.CFrame:ToEulerAnglesXYZ()
local vX,vY,vZ = Part.Orientation.X, Part.Orientation.Y, Part.Orientation.Z
print(Part.CFrame:ToEulerAnglesXYZ())
--print(Part.Orientation)
Part.CFrame = CFrame.new(Part.CFrame.Position) * CFrame.Angles(0, Y, 0)
end)
As you can see in the video, the X and Z axes are fixed at zero.
In this situation Orientation can rotate 360 degrees. But CFrame can’t spin more than 90 degrees.
Why this happen?
Try using ToEulerAnglesYXZ instead, orientation uses a “Y applied first” system just like ToEulerAnglesYXZ, while ToEulerAnglesXYZ uses an X applied first system
This can cause some big problems especially when dealing with and converting Y values and combining them with other orientations
Euler angles smell anyways but eh
They have a couple issues and aren’t the most ideal thing in the world, but are still very useful and could and should be used in many situations
They’re just a bit inaccurate in certain situations, but there aren’t very many other options
Adding onto this, Euler angles also encounter a problem called Gimbal Lock. The tl;dr of it is that you can end up losing a degree of rotation if two axes are in parallel. Here’s a gif of it in action:
You’ll notice the purple and green axes align with one another, meaning rotation only can happen on the blue axis respectively. This composes problems for game development.
If you want an anti-gimbal lock way of rotation, quaternions are the way to go. But that’s a seriously big brain topic that you can research on.
EDIT: Here’s some sauce on the topic if you’d like.