So I'm making a first person dueling system and for it I want to have 8 possible directions, all 45 degrees differentiated from each other. However to do this I need to find a way to get the direction the cameras panning. I first attempted to find the difference in camera angles using 2 look vectors and comparing the vectors using calculus (code below)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local function getDifference(U, V)
local dotProduct = (U.X * V.X) + (U.Y * V.Y) + (U.Z * V.Z)
local angle = math.acos(dotProduct/(U.Magnitude * V.Magnitude))
return math.deg(angle)
end
local function toDegrees(v)
local X = math.deg(v.X)
local Y = math.deg(v.Y)
local Z = math.deg(v.Z)
return Vector3.new(X,Y,Z)
end
mouse.Button1Down:Connect(function()
local U = toDegrees(game.Workspace.CurrentCamera.CFrame.LookVector)
wait(3)
local V = toDegrees(game.Workspace.CurrentCamera.CFrame.LookVector)
print(getDifference(U, V))
end)
The issue is that it only measures the difference between the two points, meaning you can move on different axes, and get the same result.
I later tried the same code altering it slightly to Vector2 instead of Vector3 with the same outcome.
If anyone has any ideas for a way to find the camera panning or has already solved this problem and can offer a soloution it would much appreciated.
