:Dot() Shadows issue

I was trying to code shadows from workspace:Raycast to :Dot()

So, it make shadow to everything, when it shouldn’t.
How i understand, if two vector direction same we got 0 from :Dot()

And i tried to write this code:

function pointLight:CastShadows(color, normal, hit)
	if hit:Dot((self.position - normal).Unit) > 0 then
		--local shadowRay = workspace:Raycast(hit, (self.position - hit).Unit * 1000)
		--if shadowRay then
			return color:Lerp(Color3.new(0, 0, 0), 0.55)
		--end
	end
	return color
end

Normal is raycastResult.Normal
Hit is raycastResult.Position
self.position is light position

But this code didn’t work at all, this code just makes a half of world in shadow

any help please.

I didnt know there was a Vector3:Dot() function lol

I had to look it up, but its just a dot product

basically it will return 0 if the second vector is at a right angle of the first vector

it will return 1 if its the same direction

and -1 for opposite direction

I dont know how to help you with code because I dont understand whats happening, but I hope that helped

Okay, thanks, i will try set it to -1

So, i need check if it opposite vector, it probably shadow

Okay, here is no way make it without raycast

Okay sounds good! Hope you can get it to work

Yep, i get it to work, posted in #help-and-feedback:creations-feedback