Game Development Reference
In-Depth Information
Any object can be a trigger. With a bit of script the collider that is attached to
an object won't act as a stop for other objects coming into contact with it, but
rather will make note that it's happening. On the frame that another collider
collides with an object that is designated as a trigger, other events can be
triggered via linked functions.
Designating Triggers
Any object with a collider can be a trigger. Usually though, the easiest thing
to do is create a cube (Asset>Create Other>Cube) since it already comes
with an efficient Box Collider component. Then, to make it a trigger, just
click the Is Trigger checkbox in the Inspector under the Box Collider section
( Figure 13.1 ). Then, checking off the Mesh Renderer component makes the
trigger invisible to the player.
Tutorial 13.1: Activating and Changing
Screen Hints with Triggers
In this chapter we are going to tackle a couple of Unity tricks at once. We are
going to use triggers to help the player understand where he is supposed
to go and what he is supposed to be doing. While a really elegant game will
provide this in a much more subtle way (sometimes providing a training level,
sometimes simply by great game mechanics design), for our short game we'll
be more overt and just tell the player what to do.
To do this we will first look at how Unity works with GUIText. GUIText is simply text
that is drawn on the screen above everything else; this is similar to GUITextures
except this uses a font and can be dynamic (the text can change in game).
Figure 13.1 Designating a trigger.
Search WWH ::




Custom Search