I want the camera to rotate & tween 90° whenever the “E” or “Q” keys are pressed but I’m getting funky results
A snippet of the script:
-- Camera Movement
local function handleMovement(action, state, input)
-- Rotating
elseif action == "LeftRotate" then
local cframe = {CFrame = PlayerCamera.CFrame * CFrame.Angles(0,90,0)}
-- Tween
TS:Create(PlayerCamera,
TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), cframe):Play()
elseif action == "RightRotate" then
local cframe = {CFrame = PlayerCamera.CFrame * CFrame.Angles(0,-90,0)}
-- Tween
TS:Create(PlayerCamera,
TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), cframe):Play()
The Camera already has a slight rotation to it which I believe could be the only thing interfering, for reference:
But in testing I end up getting something like this:
It’s not even rotating on the correct axis & I’m not sure why. Deleting those lines of code & simply editing the orientation directly in the properties window to read (80,90,0) like it’s supposed to, gives me the correct result. There are no errors in the console & each action only runs once without any interference from outside code
This is the camera with the above code removed, & me editing the properties directly to achieve what I need-minus the tweening:
Any help is appreciated, I’m sure my math is probably just off or there’s something I’m not accounting for.
EDIT: Still unable to solve this issue. I just need the camera to rotate 90° but I’m not sure how to set the orientation from a script. Every source I find says to use something similar to this:
PlayerCamera.CFrame = PlayerCamera.CFrame * CFrame.Angles(0,math.rad(90),0)
But it ends up rotating it incorrectly.