Now that we know how to move the player object around let’s control it. Unity already has a built in input manager with some preset controls setup. The most common in fact. We can use this to create movement controls.
With this information we know we want to access horizontal and vertical inputs and that will use wasd or the arrow keys by default. Nice and easy.
After knowing this information we can make wonderful variables out of it.
We use floats because as the player pushes on the key assigned to the input it goes from 0 to either -1 or 1 one decimal at a time. So 0.1,0.2,0.3 etc… there are uses for this information but we don’t need that now. Just remember the name of the input has to match exactly as it is shown in the input manager.
Once we have these variables set we can easily put them in place on our movement line we already created for the character. We just need to replace the player direction with the input and add it to the movement line.
There you have it! Now with these settings we have given our player control of the character using the input manager predefined keys.