local CLookVector = DotTester.CFrame.LookVector --Look vector is always the 'level' we want
local CurrentLookVector = CLookVector.Unit
local TestVector = Vector3.new(CLookVector.X, player.Position.Y, CLookVector.Z) -- x,y,z -- want the Y value to match, doesn't matter which 'level' it's brought to on the Y
local VectorToPlayer = (DotTester.CFrame.LookVector - player.Position)-- would also need to be modified by the same Y value
local dotProduct = CurrentLookVector:Dot(VectorToPlayer)
local magnitude = (player.Position - DotTester.Position).Magnitude
local laserSize = Vector3.new(1,1,magnitude)
local modPlayerPos = Vector3.new(player.Position.X, DotTester.Position.Y, player.Position.Z)
local firedLaserPos = (modPlayerPos + DotTester.Position)/2
local laserFinalPos = CFrame.new(firedLaserPos, modPlayerPos)
local staticLaserPos = CFrame.new(DotTester.Position, DotTester.CFrame.LookVector)--construct a cframe from a vector3 point, then a facing value.
local AmendedLookVector = Vector3.new(DotTester.Position.X, DotTester.Position.Y, DotTester.Position.Z)--might matter for final ray calculation, considering the midpoint
moveLaser(laserSize, laserFinalPos)--
movePart2(laserSize, CFrame.new(AmendedLookVector, DotTester.Position + DotTester.CFrame.LookVector))
------
------
------
local vector1 = workspace.raytest1.Position - DotTester.Position
local vector2 = workspace.raytest2.Position - DotTester.Position
local vector1 = vector1.unit
local vector2 = vector2.unit
local dot = vector1:Dot(vector2)
local degrees = math.deg(math.acos(dot))
In short, I am struggling to understand vectors, and how to get the angle of difference on a 2d plane between two 3d vectors. The dot product on normalized vectors with .unit returns nan(ind) for me, so I am clearly using vectors incorrectly when trying to find the dotproduct.
I have read through every single thread I can find and it appears that every answer is wrong that I have found so far, you cannot actually calculate an angle with 2d vectors with the dot product equation… so what am I missing?
In the given example, vector1 and vector2 should be right angles, and therefore return 0, however I get nan(ind), regardless of where the blocks are moved when the loop runs.