You'll never go hungry again

A function is a piece of the Script that can be executed, or called, over and over again. It's like having a sandwich that you can eat as many times as you want. We use functions to organize our code, and to house lines of code that we may need more than once.

The function we used is called Update. Just as there's an ongoing physics process in the background of our game that we can tap into to make our ball move and bounce, there's an ongoing Update loop as well. Update is eaten (or called) again and again and again while our game runs. Any Script lines, or statements, that we put inside the Update function tap into that loop.

Notice the way the Update function is declared. On a restaurant menu, we might declare that ...

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.