Raycast in Unity

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.

League of legends capture

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!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response