Creating Basic Player Movement In Unity
Creating player movement in a game is often times the very first thing any developer does after setting up their project. It allows for user interactivity during playtesting as well as world navigation all in one.
Most quality games that utilize movement in their core loop’s mechanics will add a lot of various functions to their scripts to fine-tune the mechanics to their specific goals in regards to game feel.
One simple way to get an object moving both on the horizontal axis & the vertical axis is like this…
Vector3.right = Positive X Axis
Vector3.up = Positive Y Axis
Vector3.forward = Positive Z Axis
By putting “.forward” in instead of “.up” in your Vector3 you will move your player up the “z-axis” instead of the “y-axis”.
To find the different built-in inputs go to Edit>ProjectSettings and you should see a window that looks like the one shown below. Select “Input Manager” and under the “Axes” drop menu you will find a list of all the different values that you can type in place of (“Horizontal”) or (“Vertical”) that we used above.
By changing the number for “Size” under the “Axes” drop menu, you can add any number of new input axes from which you can assign custom controls and functions to!