Game Development Reference
In-Depth Information
Foreground objects
The other thing you can do to liven up your game is to add random foreground objects
that float across your scene independently. These don't collide with anything and aren't
anything to do with the game itself. They are just eye candy to make your game look awe-
some.
The process to add these is also fairly simple, but it requires some more advanced Unity
features such as coroutines, which we are going to cover in another chapter. So, we will
come back to these later.
In short, if you examine the BackgroundPropSpawner.cs script from the preceding
Unity platformer 2D sample, you will have to perform the following steps:
1. Create/instantiate an object to spawn.
2. Set a random position and direction for the object to travel.
3. Update the object over its lifetime.
4. Once it's out of the scene, destroy or hide it.
5. Wait for a time, and then start again.
This allows them to run on their own without impacting the gameplay itself and just adds
that extra bit of depth. In some cases, I've seen particle effects are also used to add effect,
but they are used sparingly.
Search WWH ::




Custom Search