Game Development Reference
In-Depth Information
updated value back to the object. Now that you have set the bench straight, it is now safe to set the
allClear flag to true so the Translate code can send the bench on its merry way.
6.
Save the script, and click Play.
This time, the bench rotates into position and then heads out through the gate (Figure 5-40 ).
Figure 5-40. The bench, showing local coordinates, leaving the garden (Scene view)
At this point, you can add the Rigidbody component again and watch it fall as it goes out the gate.
Feel free to adjust the bench's position for a better trajectory out of the gateway.
1.
Add a Rigidbody component to the bench.
2.
Click Play, and watch (or help) it head out the gateway.
Making Use of Event-Based Functions
So far you've checked out common functionality in the Start function, where the code is evaluated
only on startup, and in the Update function, where it is evaluated every frame. Event-based functions,
however, make up the bulk of predefined functions available for use.
1.
Search the Scripting Reference for MonoBehaviour.
The Messages list shows what functions will receive “messages” or be called when their condition is
met (Figure 5-41 ).
 
Search WWH ::




Custom Search