Get Camera's Perspective and part's direction

Hello devs!

I’m trying to create a multi-directional sprite system but i’m having some problems.

I’ve started using dotproducts which it does not work pretty well.

I was learning from a tutorial about dotproducts and i thought it would work well but it didn’t.

Heres the code. (localscript)

local RunService = game:GetService("RunService")

local idle = "rbxassetid://652868915"
local notinfov = "rbxassetid://1453900693"
local notinfov2 = "rbxassetid://5800882749"

local dummy = workspace.Dummy
local character = game.Players.LocalPlayer.Character

RunService.RenderStepped:Connect(function()
	local npcToCharacter = (character.Head.Position - dummy.Head.Position).Unit
	local npcLook = dummy.Head.CFrame.LookVector
	
	local dot = npcToCharacter:Dot(npcLook)
	
	if dot > .5 then
		dummy.Torso.BillboardGui.ImageLabel.Image = idle
	else
		dummy.Torso.BillboardGui.ImageLabel.Image = notinfov
	end
end)
1 Like