Part 16 - User control.
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
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…
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.
- Part 01 - Installation
- Part 02 - Concepts
- Part 03 - Navigation
- Part 04 - Git and Unity
- Part 05 - Building a project
- Part 06 - Adding some plugins
- Part 07 - Creating some objects
- Part 08 - Physics
- Part 09 - Pushing things & animation
- Part 10 - Pushing coins
- Part 11 - Custom Scripting
- Part 12 - Spawning things
- Part 13 - It is still too fast
- Part 14 - Coins are piling up
- Part 18 - Keyboard input - Movement
- Part 19 - Deleting Coins
- Part 20 - Walls
- Part 21 - Adding a GUI
- Part 22 - Adding the GameController
- Part 23 - Scoring links with events
- Part 24 - Refining the Game - Part 1
- Part 25 - Refining the Game - Part 2
- Part 26 - Refining the Game - Part 3
- Part 27 - More refinements
- Part 28 - Slowing the user down
- Part 29 - Some more changes