Part 16 - User control.

By Jamie Chatterton / 2018-06-12

So far the coins have been spawning randomly. I guess at some point we want some user control and make a bit of a game out of it?

I think we need to add something to the Spawner to show where it is to start with.

Maybe just a cube? For simplicity's sake?

Using ProBuilder again, Click on the "New Shape" option in its window, and create a simple cube with dimensions of 1x1x1 (X Y Z) and make sure you click 'Build Cube'.

Move this cube to be a child of the spawner and change its transform to be (-0.5, 0, 0.5) so that it is sat on top of the coin. This is just so that the center of the base of the cube is the spawn point of the coins.

It hides the coin here

Open this image in a new tabHidden here!
Hidden here!

Select the entire spawner object and move it to the wall. Because of the Grid snapping, it isn't possible to move it to and position it on the wall. We can change the precision of the grid to 0.5 in it's settings (the 1 in the top of the Grid in the top left of the above screen-shot) or manually change the Z value to -0.5.

I did the latter.

The object at present will interfere with anything spawning. But we don't want that, it's just a visual representation of where things will appear. Select the 'Cube' object and delete the "Mesh Collider" Component from the cube, by clicking on the cog next to the Component title…

Open this image in a new tabDelete Mesh Collider
Delete Mesh Collider

It has the option "Remove Component". Without the collider there is nothing to collide against.

We will want to change the functionality of the SpawnerController now too.

It's not going to randomly Spawn things, but create them at the position it's placed and when the user presses a key.

Git repository: https://bitbucket.org/hiveit/unity-tutorial-coin/src/012_AddingSpawnerObjectCube/

More posts in this series.