Hi there, I am currently trying to make a Dodgeball game.
One of the fundimental parts of dodgeball as we all know is catching the ball.
I am trying to make it so only if the ball is infront of you you can catch it.
Ive tried using Dot, but this doesnt work as the balls LookVector could be different to your own whilst still being infront of you.
Heres what i’ve tried:
function DotCheck(Ball)
local dot = Character.HumanoidRootPart.CFrame.LookVector:Dot(Ball.CFrame.LookVector)
if dot < 1 and dot > -1 then
return true
else
return false
end
end
When dot prints, depending on the side I touch the ball it is different. This is expected but i don’t know a way to not have it act this way or an alternative approach.
Instead of comparing against the ball’s look vector, compare against the unit vector from the player to the ball i.e. (Ball.Position - Character.HumanoidRootPart.Position).Unit
You also probably want your comparison to be something like