Let’s cast a ray from the camera in the direction of the mouse pointer on left click and if that ray hits an object tagged “cube” it randomly changes the color of the cube. If it hits an object tagged as “sphere” it does nothing, and if it hits an object tagged “capsule” it changes the color to black.

And here’s the script we placed on the camera:

--

--

Upgrading a project from a legacy input system to the New Unity Input System is something many Unity developers will experience during their careers. It’s a common request because the new input system is so much more flexible and easy to work with.

Once the input action set is created, the process of adding it to a script is very simple:

  1. Create a reference to the input actions set
  2. Create a new instance of the input actions
  3. Subscribe to the action

Started, Canceled and Performed actions are built in and easy to reference and use.

In this series we’ve converted Player Movement and

Interactions:

Drone Controls:

--

--

There are many ways to handle player management. Here is what I would consider the preferred way…

This is an example of a clean player management setup:

The idea is that the Input Actions Script handles the inputs, the Player Management Script handles the processes triggered by the inputs, and the Player Script performs the actions of the processes on the Game Object.

In this case, we want a simple movement script. Here’s the Input Action panel:

--

--