Learn to code by Making 2.5 D Space shooter Game
Objective : Understand How to Move a Player what data type of Horizontal ,Vertical Input return
In order to make our player move we need to understand how to map player with user Input ,then configure control with UnityEngine Api
In order to to do these lets se how to move a player manually when you select a player and move by using unity navigation
In Unity api there is a class for Translate
This show this class Moves the transform in the direction and distance of
Vector3.right is equivalent to new Vector3(1,0,0) if we change to new Vector3.left(-1,0,0) the Player will move to the left.
The First Step to map the player with user input go to Edit > Project Settings > Input Manager
Input Manager uses axis to configure control to use UnityEngine.Input Api, the class is Input and method is GetAxis.
This show this class return float number in range -1…1 for keyboard and joystick
The second step is to identify axis since it is accessed by axisName, go to Edit > Project Settings > Input Manager. This brings up the Input Manager. Expand Axis to see the list of your current inputs
Second Lets declare our axis for Input.GetAxis(“axisName”);
Third Lets connect user input with player to translate according to player input
Then go to unity editor and try to use right and left key or a and d key to move our player right or left
we successfully mapped our player with user Input