Make Camera ignore Y Axis

I would like to achieve a dashing system dependent on camera rotation, I have done the basics - however the dash keeps compensating its position for the Y axis, making the forward dash dependent on if the camera is facing down or up. Please explain the math included to me as I am a bit stupid.

https://gyazo.com/bb57d75a20a91317d8cf86bd842b6e15 (facing straight forward)

https://gyazo.com/72e7ad988045b7d6b0899bc75271c4de (facing down)

My code below -

game:GetService("RunService").Heartbeat:Connect(function()
	currentCameraOrbital = Instance.new("Camera")
	currentCameraOrbital.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
	currentCameraOrbital.CameraType = Enum.CameraType.Scriptable
	currentCameraOrbital.CFrame = workspace.CurrentCamera.CFrame
	
	cameraVectorZ = Vector3.new(currentCameraOrbital.CFrame.LookVector.X, 0, currentCameraOrbital.CFrame.LookVector.Z)
	cameraVectorXLeft = Vector3.new((currentCameraOrbital.CFrame.RightVector.X * -1), 0, (currentCameraOrbital.CFrame.RightVector.Z * -1))
	cameraVectorXRight = Vector3.new(currentCameraOrbital.CFrame.RightVector.X, 0, currentCameraOrbital.CFrame.RightVector.Z)
end)
1 Like