Upgrading Controls on a Forklift to the new Unity Input System
Now that we have our player moving with the new input system, let’s take a look at how we can go about adjusting the controls for a forklift within the same test area. What we will have to do is not only change the movement controls of the forklift, but the lifting mechanism will need to be updated as well.
To start, let’s quickly adjust the code we need for the movement of the forklift:
In order to change this to the new input system, we will repeat the process that we did with our player controls:
Once we have this code switched over to our new system, we can begin to test it within our game:
Now that we have our forklift moving, let’s get to work on being able to pick up that stack of pallets in the back.
Our code originally looked like this:
What I have done to be able to have it work with our new input system is taken the same movement processes, but applied them into a Coroutine:
In order to have our lift stay still upon the player letting go of the movement key, we have removed the speed at which the lift moves to nothing. Therefore, it will just stay in place. Finally, we will add in the coroutine to our lift and lower procedures:
Now that we have this all set up, let’s take a look at how this will look within our game:
There we have it. We have successfully adjusted our forklift to move and lift/lower a stack of pallets with the new input system. Next up, we will look at how we can go about flying around a drone.