Part 27 - More refinements.
I'm going to make a number of changes now to make the game a lot more realistic.
First… the way it drops coins.
It's not realistic
Just dropping them like it does.
Most games of this type drop them from a long upright panel and let them fall down vertically.
So I'll change it to do that.
First, changing the 'wall' object to be much taller…
Moving the spawner
cube object up to the top of this. I have to change the grid snap to 0.5 to do this.
And deleting that left over coin.
I want to now change how the coins spawn, from horizontally to vertically, flush against that wall…
Honestly I think the best way is to move it so that it's resting on top of the wall…
It's going to be hard to tell…
But looking from here… Rotating around X by 90 degrees, this face facing down
Becomes that face facing out.
Selecting the 'Spawn Location' it has become
It needs to move out slightly, so when the coins spawn, they spawn above the mid-air and not the 'wall'.
I set the position to -0.1, down it's location Y axis by 0.1, so it becomes
However.. coins do not take into account the rotation of the SpawnLocation
when they are instantiated… doh!!!
Need to change the code a little!
In the SpawnerControler
we need to change the SpawnObject code a little…
void SpawnObject() {
var coin = Instantiate(ObjectToSpawn, transform);
coin.transform.position = SpawnLocation.position;
coin.transform.rotation = SpawnLocation.rotation;
OnSpawnCoin.Invoke();
}
The new line being...
coin.transform.rotation = SpawnLocation.rotation;
... so it picks up the rotation of the SpawnLocation object also.
And with that, it's immediately obvious that the position of the SpawnLocation is not quite enough… so I've set it to -0.11… and that works fine now.
This gives the following… I changed the camera angle
No explicit tag…
Git repository: https://bitbucket.org/hiveit/unity-tutorial-coin/src/685d91038df345086d35f4d1f95f6964ba9cae75/
There's an immediate problem with this, the walls need to be taller to stop coins falling off the side… so that's first…
Then let's make the front glass that channels the coins down… just duplicating a wall as a starting point and moving it into position.
After creating it and some adjustments to the width I've ended up with
It's 0.2 units thick.
It plays like …
Which then starts screaming more problems.
Git repository: https://bitbucket.org/hiveit/unity-tutorial-coin/src/991156479cda11744e100965b895b809a4ebaa7f/
The platform shouldn't go all the way back…
Back to editing the animation.
Changing the maximum back-stroke of the pusher animation to just 5, in the Animation panel, you get the problem that the coins will pile up.
Possibly the easiest way to fix this is to move the base of the back 'glass' panel up slightly. This can be done by moving the whole thing up and moving the top face back down to line up. Or just just moved the bottom face up by 0.2 units.
Either way, they don't clump and get stuck at the moment.
Git repository: https://bitbucket.org/hiveit/unity-tutorial-coin/src/d6dffd21095e0d30dfaa58120fb130ca41a7ace4/
After some messing around with the shape of the machine…
Now. It's possible to get coins jammed… I will address this in the next part.
Git repository: https://bitbucket.org/hiveit/unity-tutorial-coin/src/28e5f42a6f8c38ff790a4f56cdc1faf55933e4a3/
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 15 - Materials
- Part 16 - User control
- Part 17 - Keyboard input - Fire
- 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 29 - Some more changes