Game Development Reference
In-Depth Information
Update
Once the script is enabled and the Start() function has been called, Update() is called every frame
the game renders after that. This is the function where the game behavior is implemented. But what
does this mean?
In simple terms, games are interactive animations. Animation, or movement within the game,
works just like a video where the viewer sees a series of still images. Within each image, there is an
incremental change in the position of the subject, such that when the frames are presented quickly
in sequence, there is an illusion of movement (see Figure 4-8 ).
Figure 4-8. Frame-by-frame sequence of a UFO launching
To render a game means to draw it to the screen, frame by frame, at a rate fast enough to provide
this same illusion of movement in the game. The Unity game engine calculates everything—where
each game object is or has moved since the previous frame, each game's object based on the
location and lighting, then after all the changes in the scene are implemented, how the scene
appears from the Main Camera's viewpoint and finally renders this new frame to the screen.
Unlike videos, games have an additional element of interaction. Before rendering each frame, the
Unity engine has to calculate the changes from the previous frame based on the behavior of the game
objects as determined by each game object's components, including any scripts. Code scripted in
the Update() function drives the ongoing action of the game, as you can see in Figure 4-9 .
 
Search WWH ::




Custom Search