The new Input System: Using your new system

After some time I finally come back to talk about the new input system, I was at the creation of the first input with this new tool. Today I will see how to connect it to the player.

Once we have created our inputs we need to do two essential steps, the first is to select from the Project tab the InputAction that we have created and through the commands that we will have in Inspector go to create the correspondence class with the action map and the input that we have created.

The second thing, very important is to recall that class where we want to use it, in a very simple case we can insert it directly in the player otherwise we can go to create a manager for the management of all the inputs of the game.

Once these steps are done, the linking process is over. We need to start working on the code side to manage the various behaviors related to the events of the input system.

First of all, when we go to initialize the GameInputs object, I called it so for my choice you can use any name you prefer at the time of script generation.

after having initialized it, we are going to call the map that we want to be active. Finally, through the dot notation, we could see all the inputs we have created and recall them. Finally, we will use the appropriate callback for the event.

can be of different types:
started: the Input System has received input that started an Interaction with the Action
performed: an Interaction with the Action has been completed.
canceled: an Interaction with the Action has been canceled.

this will create the behavior that will be executed when the event is called.

Differently for the movement and the rotation we can use a more direct method using the ReadValue call inside the movement function.

Last but not least, we’ll see how to manage the keyboard and different types of controllers in the next article.




project manager by day, unity developer by night

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Postmortem:500 error outage

Project #7: ESP32 featuring Bluetooth Classic and Bluetooth Low Energy Communication Protocol!

Genymotion vs Android Emulator #17 — module security; tf+k8s

How to Best Integrate Urban Data and City APIs

SANS Holiday Hack Challenge 2020: Objective 4 — Operate the Santavator

How to add the weather forecast option to your Messenger bot

How to Install Istio in Kubernetes Cluster

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
Andrea Alicino

Andrea Alicino

project manager by day, unity developer by night

More from Medium

Loading Scenes in Unity

Creating a Ladder System in Unity — Part 1: Climb Ladder

How to set a custom Skybox in Unity!

Using Storyboards as Reference in Virtual Cameras