Unity new Input System (Part II)
We start to create a folder in our Assets, and call it Input.
Right click on the folder, Create -> Input Actions
and call it PlayerInputActions
Then, double click it.
It opens a new window
Little explanation before moving on: with this new Input system, we can literally create a different Input system depending on what we have in our game. For example, in GTA, we have the Player, but also the vehicles. So we can create various systems depending on what we need to move.
Near Action Map there is a plus button (+)
If we click on it
It opens a new menu.
I call it Player because this is the Player Input.
If we press again the + button
And we can create every type of Input we need for our game.
We back to Player Input :
as we can see, after we press +, Unity creates automatically some things for us.
It can be helpful, but to understand better, we delete it and create it from scratch.
Easy to do, go over New Action, right click -> Delete
Now, start with something easy.
We want our character to fire some projectile :
so we create a Fire action
I delete “<No Binding>”, because we create everything from scratch.
If we click “Fire”, under Properties appear some things :
Under Action for example, we can choose what type of Action we want for Fire.
Can be a button, or a value
If we choose value, under Action Type now we have Control Type, and it means this :
how we control the value?
For example can be a DPad, or Analog, or anything we think can be good
But most of the time a Fire Action is a Button, or the Space Bar.
So we set again Action Type to Button.
From here, we need to select what button is “Fire”.
How we can do?
Remeber when I delete No Binding?
Well, if click the + near Fire, we can now add the binding
To the right now we have a Binding menu,
and we can decide what key is pressed to Fire.
If we click on that “bar” right to the Path, it opens a menu.
We can faind what we need throught the varoius option, or we can click “LISTEN” and press the Space Bar
We now have our fire button set up!
Obviously we can have more than one key enabled to do the same thing.
If we make same process again, but with T Key
We now have both Space Bar and T Key for Fire!
One imporatnt thing : every time we make something inside here, we need to SAVE.
It’s really really important, so we don’t forget to click SAVE ASSETS every time we finish to create a Input.
In the next article we see how Unity reads these Input!