CFrame issue (ITS ALWAYS CFRAMES)

I am trying to make a lean system, and I am using a align orientation, but I am coming across this annoying issue:

as you can see when I exit shift lock, the character rotates to a specific point then rotates back, WHY???

local _, Y, _ = Camera.CFrame:ToEulerAnglesXYZ()
		
LeanOrientation.CFrame = CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(math.deg(Y)),math.rad(15))
1 Like

That’s because without shiftlock the character is not supposed to track the camera

this is what that does smarty pants

even with shift lock, it is still buggy

Do you want the camera to track the player at all times?

1 Like

Ok, by the way is the Torque of Align Orientation low? If so increase it

Use toEulerAnglesYXZ instead of XYZ

1 Like

I want the align orientation to follow the camera’s Y, but it stops following and turns around at some point (in the video)

still unfixed. would love some help

What is LeanOrientation in this case? Is it an AlignOrientation instance?

1 Like

@loltrol2121’s reply fixes the bug. If you are not aware, the axis order in ToEulerAngle() is important! You’ll get completely different pitch (X) yaw (Y) and roll (Z) amounts based on the order of axes rotation. In your case you’d prioritize yaw, so it should be pulled before pitch or roll via ToEulerAnglesYXZ().

Also, these calculations are redundant:
CFrame.new(0,0,0) * rotation → rotation
math.rad(math.deg(Y)) → Y

-- Fixed
local _, Y, _ = Camera.CFrame:ToEulerAnglesYXZ()
LeanOrientation.CFrame = CFrame.Angles(0, Y, math.rad(15))
2 Likes

Hi. Try using this:

local y = Camera.Orientation.Y
		
LeanOrientation.CFrame = CFrame.new(0,0,0) * CFrame.Angles(0, math.rad(y), math.rad(15))

From what I search, toEulerAngles sometimes return a different x, y, z that makes 1 rotation. Like, many different x, y, z rotation could give same exact rotation. Orientation tells exactly for example: an object is facing 45 degrees right, 90 degrees down, and 10 degrees clockwise.