Adding player movement is a basic step to make your game interactive. Here, we will explain how to add player movement in Unity. In Unity, the player is a game object, and a game object is a container of components. What components do we need to know for player movement?.
1.Transform
Every game object has a transform component by default. This component is used to define and manipulate the position, rotation, and scale of game objects.

As shown in the image above, the coordinates of a game object are stored in a vector with respective axes: X (horizontal), Y (vertical), Z (front, back).
2.Translate
Translate is used to move the transform (our game object) in the direction of translation.
After understanding some components that can help us add player movement, we will learn how players can interact with our objects.
A. User Input
Input is a Unity engine class that allows the program to detect standard user input. This time, we will learn how players move using the WASD keyboard keys. You can verify the standard input in the machine by doing the following:
Go to Edit → Project Settings → Input.

B. Player movement
Create a private global speed variable to control the speed of the player when moving. This variable will be a serialized field as you may need to access it in the inspector for adjustments. We can also set the value of Y as a global variable.

Create variables to store the directional values. These variables must be local to the Update function. Update is called every frame, which is essential to get our player moving. Time.deltaTime is used so that the movement takes place in real-time rather than by frame.


C. Use Transform.Translate to initiate the movement calculation.

D. Lastly, you can create a void method to further clean up your code.

done, that's how to add simple player movement.