I am new in unity development.And i have searched many forums for Vector Dot product. I could not understand what is the basic purpose of dot product ,Is it for direction matching of two game objects
thanks for help in Advance
it shall be highly appreciated
The dot product is the magnitude of the projection of one vector on another. It is a basic vector concept that is used in a variety of places, like projecting a point on a plane, or figuring out what side of a plane a point is on. In Unity Answers we primarily see it used to detect direction.
Given two normalized vectors, the closer they are aligned, the closer the Dot product will be to 1.0. If they were at right angles to each other, then the value would be 0.0. A value of -1.0 indicates the vectors are opposite of each other. Note that it is not a linear progression. That is a value of 0.5 is not mean the two vectors are 45 degrees away from each other. If you need a linear progression, use Vector3.Angle().
For example, say you had a pair of dice and you want to check each one for which side was up. You could use Vector3.Dot() with each of the transform sides (transform.forward, transform.right, transform.up) against Vector3.up. A value near 1.0 would indicate that side was up. A value near -1.0 would indicate the opposite side was up. If none of the values were near 1.0, you would know the die was not resting flat on a surface.