Unity New Input System (part 2)

Challenge: Converting Old Input System to New Input System

Creating the Input Manager:

So to start, we are first going to create an new C# script called “Input Manager”. Then we are going to create an empty game object within the scene which will house this Input Manager script.

I also assigned an variable for the Player script as well.
By making it pass in a Vector3 zero, that means on all axis will equal to 0.
By passing this vector3 value to the Player script, the player will now be able to understand which direction we are headed.

The Player Script:

To solve the error that is happening on the Input Manager script, we just need to create an new public method within the player script using the same namespace that we provided. (in this case we used the namespace “InputMovement”.

Make sure to pass in the Vector3 variable when creating the public method.
private vector3 variable within the Player script.
The Player is now moving with the new Input System.

The Interactive Zone Script:

Now that the movement function is completed, we can move on to the next step which is creating the collect and action function. During the inital play through of the prototype, we noticed that the game requires the player to be able to collect objects and also be able to use those objects with an action toggle. This action toggle is also able to trigger events within the interactive zones.

Having the same key blinding is ok as long as the scripting functions don’t overlap (aka I am not calling on Action and Collect at the same time in my script)
The preset 3 Zone Type in the interactable zones should corresponded to the Input Actions
The scripts inside the this performed function is actually copy and pasted from the previous script.
The player can now collect items using the “E” key

Input Manager Script:

For the Drone and other vehicles which the player will encounter we will be controlling all input functions via the Input Manager, that way we can have a more organized and easier debugging control. But before we can start scripting with the Drone script, we must create the key bindings within the Action Map.

This is the completed version of my Input Action Map which has future Maps such as Fork Lift and Menu.
The Flying Method houses all the Drone Performed and Cancelled Actions.

Drone Script:

Back in the Drone script there are several things that we must add before we can make the connection between Input Manager and the Drone script. First we will need access to the Input Manager. Then we are going to create 3 private local variables (2 Vector3 and 1 float value).

Each movement method is now being controlled via the values from the Input Manager.

Working with Other Scripts:

Since we have a proper understanding how to incorporate the Input Manager with the existing scripts, the rest of the scripts can easily be finished by replicating the same procedures from converting the Drone script.

--

--

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.