When distance is = Vector2.Zero, then Normaize fails with NaN.
A nicer solution is to first get direction.Length() , check if it’s zero, and then normalize ‘direction’ manually by dividing direction/length. (it’s faster too since you skip an extra Sqrt.)
Ok, why doesn’t Normalize return zero then? It’s complicated! A zero result would still be wrong, It’s not a valid normal. It seems to fit in this situation but in many general cases it doesn’t work.