Game Development Reference
In-Depth Information
Figure 3-16. Updating the Prefab setting
Once you have updated the prefab, it is no longer required in the scene.
2.
Delete the BigTree prefab from the scene.
3.
Select the Terrain object in the Hierarchy view.
4.
In the Paint Trees section, click the Refresh button to the right of the Edit
Trees button.
5.
Click Play, and test the rest of the BigTrees by trying to drive through them.
6.
Stop Play mode.
Physics
As computers have gotten faster, it has become feasible to use physics to control a lot of game
action. Accurate algorithms are still too slow for real-time, however, so game physics are still only
rough approximations. Because most game physics are used for mayhem and destruction, this is
perfectly acceptable.
The big gain by applying physics to animation projectiles, collisions, and other actions has been
to significantly reduce the need for traditional key-frame animation. It also has a side effect of
automatically adding a good measure of randomness to actions. If you do need a specific result,
you will be better off using a pre-made animation, though even that could be inserted into a string of
physics-driven actions to preserve the illusion of randomness.
Game physics are not a silver bullet (pun intended). Physics-driven objects will not yet perform true
to life. As far as frame rate goes, it continues to be too costly to do so. The most typical example of
this is shooting a projectile at a wall. If the frame rate is too slow, the projectile could be in front of
the wall at one frame when it is checked and beyond the wall in the next frame. Since an intersection
was never detected, no reaction ever occurs. Physics intersections may be checked more often than
every frame, but the concept remains the same.
Rigidbody
The two most important ingredients for using in-game physics are the collider and Rigidbody
components. The collider defines the physical boundaries of the object, and the Rigidbody
component handles the physics that do the work. Scenes already have default “gravity,” but you can
also add forces and torque to physically move or rotate objects. To make things more interesting,
 
Search WWH ::




Custom Search