I want to check if a part is facing a certain point in the world (Vector3). In my case, the point can be very very far away so I don’t think a recast could cut it. I tried using the :Dot() function but I cant seem to get it to work. Any help?
I think you could still achieve this with :Dot() Product, here’s a video if you want that might answer some questions?: Vector3 Dot Product: Calculating NPC Field of View (Roblox Studio) - YouTube
Sorry if this wasn’t a big help, I’m not a great scripter
Do you have Streaming enabled?
:Dot() would work. They coudl try a function like:
local function GetFacingScale(part, point: Vector3)
return part.CFrame.LookVector:Dot(point-part.Position).Unit — returns -1 through 1
end
A Dot Product is a single Number that is given by multiplying a points axis with another points axis, aka if you have these two points:
(13, 20, 5) (1, 8, 10)
You Multiply the x axis with the other x axis, and continue the same process while adding them together, and so on.
(13 x 1) + (20 x 8) + (5 x 10)
Which from this example, we get 223 as our Dot Product.
Because the Dot Product is a single number, and not a Vector, .Unit
will not work here, therefore this code will not work.
I forgot my parantheses.
local function GetFacingScale(part, point: Vector3)
return part.CFrame.LookVector:Dot((point-part.Position).Unit) — returns -1 through 1
end