Game Development Reference
In-Depth Information
Step 9. Play. The plane will always face the player. If the grass texture
appears upside down on the plane, set the y tiling value to 1 in the
Step 10. To see the full effect, duplicate the basicPlane object four or
five times and move them around to create a bunch of grass. Play and
walk around.
Step 11. When you walk over the top of the grass it will lay down flat.
If the billboard were a tree you wouldn't want this to happen. Rather,
rotating around the x axis should be turned off. That way the object
will stay vertical and only turn around its y axis. To allow for this,
modify billboard.js to the code in Listing 2.24 .
Listing 2.24 Billboarding Script That Allows the x Rotation
to Be Turned Off
var StayUpright = true;
function Update()
transform.eulerAngles.x = 0;
Step 12. Play. The grass will not bend over as the FPC approaches it. You
can now turn this feature on and off using the tick box for StayUpright in
the Inspector when billboard.js is attached to a game object.
More often than not, billboards are used on horizon lines and in the distance.
Because they do not stand up under close scrutiny, you may want to use them
on mass, but in areas of the game environment the player can't quite reach.
2.8 Summary
This chapter covered a variety of techniques for replicating real-world
mechanics in a game environment. These have included movement with
vectors and the physics system and optimization techniques that make the
virtual world seem as extensive as the real world.
Most often satisfactory movement in a game environment can be achieved
through knowledge of vector mathematics. Applying this first before jumping
headlong into the physics system will optimize processing of the game
environment. For example, in the rocket ship hands-on session, physics
could have been employed to push the rocket ship around the planet.
This would, however, have been overkill, as only a simple translation
and slerping algorithm was required.
Search Nedrilad ::

Custom Search