Simple Player Movement in Unity-Day 3
Objective: Move the player character across the screen.
Create a Player script and place it in a new folder called Scripts. This is the Player class and component. The file name and class name must match or you’ll get an error. Drag the Player script onto the player object.
To set the player’s position, refer to the transform. When assigning a new position, always give it a new Vector 3.
The above code places the player back at the 0,0,0 position.
Fast Player Movement
To move the player fast, translate the direction of movement within the transform like this : transform.Translate(Vector3.right); This will make the player zoom to the right. Or you can do : transform.Translate(new Vector3(1, 0, 0)), which means moving one unit to the right. To move to the left replace Vector3.right with Vector3.left or transform.Translate(new Vector3(-1, 0, 0)).
Normal Player Movement
In order to make the player move normally instead of flying off the screen, multiply the Vector by Time.deltaTime, which is the equivalent of one meter per second. This allows you to use real time. To move at five meters per second, multiply the Vector and Time.deltaTime by five.