Working With Raycast:

Learning how to use Raycast within Unity

What are Raycast?

Raycast is basically an laser that is sent from usually the player location either from the dead center of the screen or where the mouse cursor location is currently located. The laser would hit an object and return back to the player with data informing what the object the cast hits and where it is on the active scene.

How to script with Raycasting:

In order to understand how Ray casting works, we will do a quick demonstration, we are going to create a 3D cube on the new empty scene and whenever the left mouse button is clicked on the cube, the color of the cube will change.

A basic cube which will change color later one clicked by the left mouse.
The main camera now housing the Player script.
Download and install the New Input System since we will be using that for this Raycast project.

--

--

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.