How Vector2.Dot works? (SOLVED)

I’m trying to understand how Vector2.Dot works…
According to unity docs, these 2 should print the same thing, but it doesn’t:

float projection = Vector2.Dot (velocity, currentNormal);
print(projection);

print((velocity.magnitude * currentNormal.magnitude) * Mathf.Cos(Vector2.Angle(velocity, currentNormal)));

Can someone help me understand what actually is being calculated through the Dot function and how the return value is achieved?

https://docs.unity3d.com/Manual/UnderstandingVectorArithmetic.html

Most likely the problem lies in the Mathf.Cos which, if I recall correctly, uses radians. In that case you should multiply the Vector2.Angle by Mathf.Deg2Rad

2 Likes

Oh man, that was actually the problem. I thought I had already checked for that but I must have done it wrong. Using your method got it to work!

Thank you sir.