Game Development Reference
In-Depth Information
Figure 4-3. Sprite objects are 2D and have no thickness. Consequently, they look like cardboard cutouts
One way to fix this is to code a Billboard . When you add any code to a sprite, forcing it to rotate
so that it always directly faces the camera as it moves around in the level, you create a Billboard.
In short, a Billboard refers to a sprite that's always looking at the camera. It always rotates in
synch with the camera so that the camera sees the sprite head-on . This eliminates any distortion
and flatness arising from the camera seeing the sprite at other angles in perspective—because,
with Billboards, the camera can only ever see the sprite from one angle and one angle only. In this
section, then we'll code a Billboard class that we'll add to the Cash Power-Up (as well as all other
power-ups) to solve the problem of sprite flatness. Create a new C# script file and begin with an
empty class, which I've named Billboard . Then add this class as a component of the sprite object in
the scene (see Listing 4-1).
Listing 4-1. Billboard.cs: The Beginnings of a Billboard Class
using UnityEngine;
using System.Collections;
public class Billboard : MonoBehaviour
{
}
 
Search WWH ::




Custom Search