Game Development Reference
In-Depth Information
100.
}
101.
102.
//Move the character
103.
transform.Translate(speed);
104.
105.
//Apply gravity to velocity
106.
if(transform.position.y > 1.0f){
107.
speed.y = speed.y - gravity * Time.deltaTime;
108.
} else {
109.
speed.y = 0;
110.
Vector3 newPosition = transform.position;
111.
newPosition.y = 1.0f;
112.
transform.position = newPosition;
113.
}
114.
}
115.
}
Listing 9: Implementing the first person input system
As you can see, some parts of the code are familiar since we have already dealt with them.
You can refer to Listing 6 in page 26 to read the discussion over parts such as jumping.
Search WWH ::




Custom Search