Hooking It All Together

It’s almost ready to work, but we still need to plug the appropriate objects into the public variable fields we’ve created for our CoinSpawner Component. We’ll start by telling the Component where the spawn point is:

1. Select the boxCoin_disabled GameObject in the Hierarchy.

2. Drag the boxCoin_spawnPoint GameObject onto the “Coin Spawn Point” property of the Coin Spawner Component.

We still need to plug in the Prefabs for our coins, but these are a bit different. We won’t be dragging them from the Hierarchy onto the property fields because we plan on instantiating them. This means that they don’t already exist at runtime and will be created from a Prefab template instead. The following steps will finish setting up our ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation 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.