Game Development Reference
In-Depth Information
Edit your code as follows:
#pragma strict
function Start () {
var someCondition : boolean = false;
do
{
Debug.Log("Print something anyway");
}
while(someCondition == true);
}
Here the first thing you do is set the variable someCondition to false . After the keyword do , the body
of the do statement is executed once before it gets to the while statement, where it finally has a
condition to test. Based on your variable declaration, the conditional will resolve to false and the
program exits the loop. Run your script, and the “Print something anyway” line appears once in the
console as you expected.
The difference between a for loop and a while loop may not seem obvious, but you will get practice
using these in upcoming demonstrations. You will get a much better feel for loops and when to use
the various types in the context of game development.
Coordinate Geometry and Vectors
Okay, time for a little huddle. This topic is written with the beginner in mind. Not the beginner who
happens to have an advanced degree in mathematics, but the average person who happens to have
an interest in game development . . . though of course I think that makes you much cooler than the
average person. If you happen to have that degree in mathematics, then you will appreciate the
elegant genius that it takes to make such a complex development tool like Unity so user-friendly.
You don't have to understand combustion-engine theory to drive a car, solid-state circuit design to
use a computer, or anything about electric motors to use a drill. Most importantly, you don't have to
be a math whiz to learn to develop games. You'll definitely pick up more than you might think as you
go, and it won't even hurt. I promise.
The creators of Unity intend for it to be intuitive, meaning easy to use and understand, and they have
been incredibly successful. “Intuitive” also means having a feeling or instinct for how something
works, which you will quickly learn by doing. Experimenting to see what happens in your game is
how you develop this intuition. Even when I wasn't just fooling around on purpose, I can't tell you
how many times the difference between what I thought I told Unity to do and how it interpreted
my scripts gave me unexpected results. But my computer never blew sparks or melted down, and
often that botched result was as funny as a movie blooper. Learning game development really is
entertaining—have fun with it!
Most games, especially 3D games, are all about movement. Vectors and Transforms are respectively
some of the most commonly used structs (see hereafter) and classes that you will use. They describe
where your game objects are and how they move. This section is a brief review of the basics of
coordinate geometry and vector mathematics, along with the associated Unity variables and functions,
 
Search WWH ::




Custom Search