Unity Tutorial 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;

The new line being the

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 COMMIT 685d910 (Master branch) "changing spawner"

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 9911564

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 d6dffd2

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 document.

For now

GIT TAG 023_GameRefinements2

Unity - A simple tutorial < Unity Tutorial 26 - Refining the game part 3 Unity Tutorial 28 - Slowing the user down >