Videos

[Video] Unleash the Power of Raycasts with Dot Product

This Unity tutorial will show you how to dramatically improve your raycasts using the dot product of two vectors.

Unity’s built-in Raycast function is an extremely valuable tool. It allows you to cast a ray into the scene and determine whether or not it collides with anything. This is useful for common mechanics such as line-of-sight and collision detection.

But sometimes Raycast can be too precise, and using it can result in an unresponsive feel for the player. Luckily, we can use the dot product in cases like this to simply determine whether or not a ray is close to a target.

This unity tutorial uses basic object selection as an example to demonstrate how powerful this simple algorithm can be.

Learn more about Dot Product at https://betterexplained.com/articles/vector-calculus-understanding-the-dot-product

📦 Download the project at https://www.patreon.com/posts/27222309

Newsletter

Subscribe to my email newsletter for Unity programming tutorials and content related to game development.