Game Development Reference
In-Depth Information
The
Start
function, you learned, was a great place to initialize and even override values in the
Inspector because it is only read onceāat start up. As you experimented with the variables, you
made use of the console, both to help troubleshoot errors and to report on the state of your variables
through the use of the
print
and
Debug.Out
functions. Comments, you found, could be used to leave
notes about your code and to disable code.
Continuing with functions, you discovered the MonoDevelop script editor helped you with both
syntax and layout as you began to write code that made use of your earlier variables. You got quite
a bit of practice with the
if
conditional as you learned how to control which code was used in the
Update
function that is called or evaluated every frame. Variables storing the state of things were
especially useful as flags in that particular scenario. You also discovered
Time.deltaTime
, the main
ingredient to turn frame time into seconds when animating things in the
Update
function.
Finally, using
SendMessage
, you were able to send a message from one script after an event-driven
function was triggered, to affect the functionality of the parent gameObject from another script. In
doing so, you also designed your first user-defined function. The main concept, you found, was that
it was crucial for scripts to be able to communicate with other scripts, both on the same gameObject
and on any others, to control functionality in your game.