Game Development Reference
In-Depth Information
You can attach this script to the main camera, and set the root of the vehicle as the car to
be followed by the camera. Now you have a vehicle that can be controlled using physics
simulator, and you are ready to take a ride. Do not forget to add a ground before running
the game, in addition to some obstacles like humps; in order to test how they effect the
vehicle when driving over them.
Now we are going to perform some cosmetic enhancements to our vehicle. The vehicle is
already functional and behaves as it should, but it does not reflect its state visually. First
of all, we need to be able to see the wheels spinning as the vehicle moves. Additionally,
we need to visualize the steering angle by turning the front wheels left or right. Finally,
we have to visualize the effect of suspension springs by moving the wheels up and down
relative to the car body. The common thing between these three visual enhancements is
the fact that they are all applied to the visual wheels of the car. Therefore, we are going to
write a single script, CarWheelAnimator , and let it do the job for us. This script is shown in
Listing 46.
Search WWH ::




Custom Search