Game Development Reference

In-Depth Information

localScale = new Vector(1,1,1)

localScale = new Vector(0.1,1,1)

localScale = new Vector(2,2,2)

localScale = new Vector(0.5,0.5,0.5)

Fig 2.15
Scaling an object.

or all at the same time using a vector like this:

this.transform.localScale = new Vector3(3,0.5,10);

Values for the scale are always multiplied against the original size of the

object. Therefore, a scale of zero is illegal. If a negative scaling value is used,

the object is flipped. For example, setting the
y
axis scale to
−
1 will turn the

object upside down.

Taking some time to orient yourself with both 2D and 3D space is necessary to

understanding how objects will move around within your game. Fortunately,

Unity takes the hard mathematics and hides it behind many easy-to-use

functions. However, when something goes wrong in your game, it's nice to

have some idea where to start looking.

2.3.4 Polygons and Normals

Chapter One introduced polygons as the small shapes, usually triangles and

sometimes squares, that make up 2D and 3D meshes (or models). A polygon

in a mesh also represents a
plane
. A plane is a 3D object that has a width

and height but no depth. It is completely flat and can be orientated in any

direction, but not twisted.