I’m about a month or so into scripting and I’m not very great at explaining things so please bear with me.
I’m trying to write a script that will print the dot positions of a camera’s look vector and a block’s look vector, right vector, and up vector if the camera is facing away from the block (otherwise, just don’t print anything at all.)
Below is said script:
local block = game.Workspace:WaitForChild("block")
local cam = workspace.CurrentCamera
while wait(1) do
local camV = cam.CFrame.LookVector
local bl, br, bu = block.CFrame.LookVector, block.CFrame.RightVector, block.CFrame.UpVector
local dotl, dotr, dotu = camV:Dot(bl), camV:Dot(br), camV:Dot(bu)
if dotl <= (-0.54) or dotr <= (-0.54) or dotu <= (-0.54) then
print(dotl)
print(dotr)
print(dotu)
end
end
The script works fine and prints the dots when you’re looking at the face of the block, the right of the block, and above the block. However, if you look at the left of the block or behind the block, the script doesn’t print anything at all. I’m assuming it’s because looking at the left or back of the block counts as facing away from it to the script.
I’ve tried using a raycast from the camera’s position to the block’s position and I’ve also tried switching up the numbers and adding additional conditions to the if statement, however, none of them worked and some even resulted in nothing happening at all. I’ve looked through the forums for some answers but I couldn’t find any answers.
What are you trying to do with this script when you get these values?
If you describe what you are trying to accomplish in game (like a direction finder or an arrow to point the direction to the block using a GUI but only when looking away from it) then someone else may have a better understanding of the problem and be able to solve it for you.