Game Development Reference
In-Depth Information
Figure 15.6 Loads of rays being
casted (represented in yellow);
all from adjusting one prefab and
applying the change.
Why?
And just like that all the cameras in the level can “see.” Quick and powerful
prefabs are. Next—tags.
Tags
Thus far, our scripts have identified objects by their names (hit.collider
.gameObject.name == “Object's Name”). There is something direct about this
method because we have the script looking directly for something solely
based upon the name we typed. However, this can also be fairly brittle as well.
Especially during the prototyping process, objects can very easily end up
renamed in either Maya or Unity to help suit this artist or that scripter. If this
happens, all the scripts that are looking for that object by name break. It can
be pretty icky trying to track down which script called for that object by name,
especially if you don't know what the name was. Alternatively, Unity can compare
other attributes as well. One of my favorites is to compare an object's tag.
When any GameObject is selected in the Hierarchy, the Inspector will
allow for the object to be given a tag and/or assigned to a layer. By default
the tag on objects is set to Untagged. To assign a tag to an object, just use
the drop-down menu next to tag in the Inspector ( Figure 15.7 ). While we're
Figure 15.7 Assigning a tag
to an object.
Search WWH ::




Custom Search