Summary
We have created our first real scripts, which provide useful behavior. We discussed how to instantiate Prefabs via scripting, to create objects at will according to the game situation. Also, we saw how to schedule actions, in this case, spawning, but this can be used to schedule anything. Finally, we saw how to destroy created objects, to prevent increasing the number of objects to an unmanageable level. We will be using these actions to create other kinds of objects, such as sounds and effects, later in this book.
Now you are able to create any type of movement or spawning logic your objects will need and make sure those objects are destroyed when needed. You might think that all games move and create shooting systems the same way, and while they are similar, being able to create your own movement and shooting scripts allows you to customize those aspects of the game to behave as intended and create the exact experience you are looking for.
In the next chapter, we will...