GDD Lab#3
GDD Lab#3
GDD Lab#3
Lab Manual# 3
First Person Character
movement using keyboard
Course Instructor
Khawaja Ubaid ur Rehman
Pre-requisite
Lab 2
1. Add a 3D object Capsule to your scene.
2. Change the Camera preview w.r.t Player. Adjust the camera position in such a
way camera position and player position is same.
Character controller:
It is used to handle player movement and collision detection.
Serialized Field:
It is used if you don't want to access variable elsewhere, but you want to set value in the
inspector.
8. Make the following variables to store x-axis and y-axis movement values.
Horizontal is pre-defined keyword used to get input along x-axis in Unity’s Input
Manager.
Time.detlaTime: Interval in seconds from the last frame to the current one.
10. Type the following line of code in Update function to store input along z-axis.
Vertical is pre-defined keyword used to get input along z-axis in Unity’s Input
Manager.
11. Type the following line of code in Update function to move your player along
x-axis. By writing this line of code you can move your player in left/right direction
using A,D, left and right arrow keys.
12. Type the following line of code in Update function to move your player along
z-axis. By writing this line of code you can move your player in forward and
backward direction.
Lab Tasks
1. Add a component of Character controller to Player in Unity inspector window
and assign character controller as a reference to that game object.
2. Adjust the camera position in such a way camera should follow player. [Hint:
Make camera as a child of Player]
3. Add fog to your terrain.
4. Add grass to your terrain.
5. Change the sky box material. Download “Sky5x One” asset from Unity asset store
and import it to your scene. Change sky box to night.