Objective: At the end of the guide the reader will learn how to make a raycast inside Unity.
What’s a Raycast?
Ray casting refers to the use of the ray-surface intersection to solve a variety of problems in computer graphics and computational geometry. — Wikipedia
When should we use them?
There are a bunch of case scenarios where we can use the raycast technique in Game Development. Like for example, imagine you wanna move the character to the mouse position but converted in world space position, like in top-down games like League of legends.
First we have to add a NavMeshAgent component to our player.
You should create an static object to set it as walkable area setting it by static
Then we have to create a NavMeshSurface so Unity will know which are the walkable objects
Now it’s time to create our movement script!
Attach it to the player and it will move!