Game Development Reference
In-Depth Information
Frame 1
Frame 2
Frame 3
Frame 4
Start {
(script enabled)
}
Update {
move up
}
Update {
move up
}
Update {
move up
}
Figure 4-9. Sequence of rendered frames with corresponding script function calls
Scripting in Start
In the Unity editor, select the Snazzy Cubes object in the Hierarchy view. In the top menu, select
Edit ➤ Delete. Since Snazzy Cubes is a parent object, when it is deleted, all of its child objects are
deleted as well. In this case, all of the cubes disappear from the scene.
Create a new game object using the Hierarchy view by selecting Create ➤ Sphere. As expected, a
sphere appears at the origin (0, 0, 0). Select Main Camera, and drag the sphere from the Hierarchy
view into the Target property of the MouseOrbit script component.
Select the light in the Hierarchy menu. Set the Transform Position property to (0, 5, 0), and the
Rotation property to (0, 30, 0), and make sure the type is Directional.
In the Project panel, select the Assets folder. In the Project panel control bar, select Create ➤ Folder,
then name it Scripts. It's important to develop the habit of keeping your game assets organized. You
will see your new Scripts folder appear in the Assets folder (Figure 4-10 ).
Figure 4-10. Creating the Scripts folder in the Project panel
With the new Scripts folder selected, select Create ➤ Javascript and name the new script
SphereColor (Figure 4-11 ).
 
Search WWH ::




Custom Search