CFrame Camera Tilt Bug

I’m trying to build a physical menu on a surphace gui. This needs manipulation of both camera position and part position.

Whenever I change the orientation value to the camera via property selection, it works completely normal. However, when I put the same exact values in a script, it puts the camera at a somewhat 10 degree tilt on the Z axis.

Working Example using Property Menu


Camera Tilt With CFrame Issue

  • Current Trial Code -
local TS = game:GetService("TweenService")

wait(1)

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local r = math.rad

cam.CameraType = Enum.CameraType.Scriptable

cam.CFrame = CFrame.new(Vector3.new(-35,21,49))*CFrame.Angles(r(-16.5), r(-37), 0)

I’ve looked thru the dev hub but I couldnt find a topic related to this issue.

Ive found some issues involving tilt, but this seems different somewhat.

Thanks!

Try Use a TweenService to smoothly transition the camera’s CFrame:

  • Instead of setting the camera’s CFrame directly, you can use the TweenService to smoothly transition the camera’s position and orientation.

Using tween_service is in the plans, but I am tweening the CFrame. This will make 0 different to the camera tilt bug. By the way I tested it out just incase.

JUST TEST CODE (formatting is horrid)

local TS = game:GetService("TweenService")

wait(2)

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local r = math.rad

cam.CameraType = Enum.CameraType.Scriptable

local t_info = TweenInfo.new(1.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local t_goal = {
	CFrame = CFrame.new(Vector3.new(-35,21,49))*CFrame.Angles(r(-16.5), r(-37), 0)
}

local tween = TS:Create(cam, t_info, t_goal)
tween:Play()

For the camera tilt bug it might be a scripting problem or a glitch I don’t know yet but send it to the DM of Roblox administrators

local lookAtCFrame = CFrame.new(Vector3.new(-35, 21, 49))
cam.CFrame = lookAtCFrame:toWorldSpace(CFrame.Angles(r(-16.5), r(-37), 0))

local t_info = TweenInfo.new(1.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local t_goal = {
    CFrame = lookAtCFrame * CFrame.Angles(r(-16.5), r(-37), 0)
}

local tween = TS:Create(cam, t_info, t_goal)
tween:Play()

Using lookAtCframe

Sorry but using the same cframe input isnt changing the tilt values. I did test your code out though.

SOLUTION!

Important info → read

Apparently EulerAngles order of rotation matters a lot!
To solve this, you want to use:

CFrame.fromEulerAngles(radX, radY, radZ, Enum.RotationOrder.--Any Option--)

Find what RotationOrder lines up best for you

UPDATED WORKING CODE

local TS = game:GetService("TweenService")

wait(2)

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local r = math.rad

cam.CameraType = Enum.CameraType.Scriptable

local t_info = TweenInfo.new(1.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local t_goal = {
	CFrame = CFrame.new(Vector3.new(-35,21,49))*CFrame.fromEulerAngles(r(-16.5), r(-37), 0, Enum.RotationOrder.YXZ)
}

local tween = TS:Create(cam, t_info, t_goal)
tween:Play()

Works as expected now!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.