Game Development Reference
In-Depth Information
Boolean Values The next type of information you can store in a variable is the Boolean
value type. Boolean values are true or false statements that can be used to switch objects
or functions on and off:
var inChapter10 : boolean = true;
String Values Strings are simply one or more words (“strings” of letters) that can be
stored in a variable:
var getAtStore = “Milk“;
GameObject A GameObject variable allows you to store an entire in-game object in a
variable to be used later.
var crate : GameObject;
You declare GameObject variables when you are trying to identify objects according to
components or tags. With GameObject, it is also possible to declare an array, or a listing
of multiple objects, by adding two brackets to the end of the class type in the variable:
var crates : GameObject[];
You might use an array if you are asking the script to choose game objects from a list of
objects in the scene.
Additionally, you can declare more specific types of objects, such as particle emitters and
mesh renderers, as variables:
var Fire : ParticleEmitter;
var muzzleFlash : Renderer;
Transform A transform variable is similar to GameObject, but it also gives you access to
the transform data—location, rotation, and scale—of the object.
var ZombieObject : Transform;
One useful application for transform variables is to designate objects that can be created
and launched (known as instantiation) by other game objects. Later in the chapter you
will utilize a transform array to create a zombie spawner:
var ZombieObjects : Transform[];
Collision In video games, game objects collide and crash into one another a lot and cool
stuff is supposed to happen when they do. By declaring a collision variable, you can tell
the game what to do when certain objects are collided with:
var hit : Collision;
AudioClip and Animation Classes The last variable types that you will learn about here are
those for audio and animations. These two classes allow you to specify audio assets or
animations to be played with specific game actions.
var gunSound : AudioClip;
var walkAnimation : Animation;
Search WWH ::




Custom Search