I am trying to make the camera roll with the aircraft but cannot for the life of me wrap my head around as to why the rotations are so off when the aircraft starts to roll.
Here is a video as to what is happening
Below is the code I use for the camera function
local plane = game.Workspace:WaitForChild("Plane")
local currCamera = game.Workspace.CurrentCamera
local function cameraMovement()
currCamera.CameraType = "Scriptable"
currCamera.CFrame = CFrame.new(plane.CFrame.Position + plane.CFrame.LookVector * 80, plane.Position) * plane.CFrame.Rotation:Inverse()
end
game:GetService("RunService").RenderStepped:Connect(cameraMovement)
I just want the camera to roll and follow the aircraft.
If anyone has any advice or could point me in the right direction to fixing this would be greatly appreciated!
local plane = game.Workspace:WaitForChild("Plane")
local currCamera = game.Workspace.CurrentCamera
local function cameraMovement()
currCamera.CameraType = "Scriptable"
local cameraPos = plane.Position + plane.CFrame.LookVector * 80 + plane.CFrame.RightVector * -20
local x, y, z = plane.CFrame.Rotation:ToEulerAnglesXYZ()
local cameraRot = Vector3.new(0, y, z)
currCamera.CFrame = CFrame.new(cameraPos, plane.Position) * CFrame.fromEulerAnglesXYZ(cameraRot)
end
game:GetService("RunService").RenderStepped:Connect(cameraMovement)