# Difference between cframe and orientation

In Orientation

``````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?

you can do everything with cframe rotate and move, just more efficient. id recommend researching it.

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

1 Like

What is smell
Euler angle is a bad way?

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

1 Like

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.

4 Likes