Welcome back My favorite game developers
to a brand new video and this one,
instead of just adding the points
to our layer or to our game manager,
we actually have this coin right here.
And as you can see, it rotates.
It's really cool.
And if you hear when we pick it up,
there is a small explosion.
Why an explosion?
Because I didn't take the time to actually find
some sound effect for the picking up of the coin.
So with that of the way,
let's not waste any more time and let's get started.
Oh, okay.
So time to start actually
picking up the money that we've created.
So I'm going to clear all of this.
I'm going to open the script and
remove what we have in here for
the BBC or whatever it
is displaying and adding using the keyboard.
So back in here way for it to compile.
And in the sprites in here,
I'm going to create a new folder for the coins.
Double-click, open this up and I'm going
to go into the resources in here.
And as you can see,
we have the rotating coin,
the coin blink and the coin shine.
So choose whichever you want.
I want the rotate because I like to see the coins rotate.
So at this end here opens up.
Let's see what these look like.
Really nice coins, but I feel that they might be a
little bit out of place with
the 2D graphics that we have,
but no worries, we are using
free assets from open game art.
So there we go.
We add this in here.
This will be a huge coin.
Prepare for the huge Coyne.
Whoa, I never thought,
I really didn't know this coin would be that huge.
So let's make it a bit smaller.
Even more.
So 400, lets see.
We can, by the way, you make the scaling a bit smaller,
but I like to change the pixels per unit.
And even this, Let's make it 800.
So we make two
times smaller than whatever it is right now.
That's still huge.
And let's make it 1600.
So come on, please.
We needed a bit smaller.
Oh my God.
I would not expect this amount.
3500 seriously, this should be very small right now.
Okay, Great.
So I think this coin, There we go.
So this is a small coin that is
going to be rotating around and we can pick it up.
And actually, you know what,
maybe make it 3000.
And there we go, apply the changes.
Let's make it point.
Point, and we don't need to make multiple.
There we go, save that.
Now this is going to be the Bitcoin 0 case.
So now what we're going to do is we're going to
go into the animation and create an animation.
So an asset's animations right-click New Folder,
rotating a Bitcoin, double-click in here and rotate.
That's it.
All we need to do.
A drag these n and that's right.
Okay, that's too fast.
Let's separate them a bit.
So every point, there we go,
I think this is a good enough rotate.
So and for some reason I feel
that it's a bit annoying, but no worries.
Now we're going to go ahead and add a new script in here.
So I'm going to go into
the scripts and to worship into the pickups.
Right-click and create a new C-sharp script,
which is going to be the go and pick up a coin.
Pick up.
There we go. So now we have the coin pickup.
Let's make that smaller. There we go.
So added to the Bitcoin and
let's open it up and Visual Studio.
So if I go get the health pickup,
it's pretty much the same.
So where is it?
Where is the health pickup?
So this is pretty much the same.
I'm just going to copy the code.
I'm going to paste it in here.
And the only things that are
going to change as for example,
the coin amount that you will get from this coin,
so I'll keep it at them.
And maybe also the picked up,
which is going to be good and pick it up.
And k can be picked up method.
Okay, so the pickup, the layer.
That's obviously something that we are also
going to add to the coin because later on
we will want to maybe break a jar or kill an enemy.
And so we want to have a bit of a delay.
So at anytime now we are going to make this smaller
at component the layers
or pick up the layer. There we go.
Time before pickup is 0.5,
which is good enough for us.
And then in here,
what else do we need to do?
We destroy the game object.
We, instead of adding HP,
we are going to remove this.
And we are going to make sure in here,
we can also remove the player
will set it on the pickup layer.
So pickups.
And remember we stopped using the layer, layer.
I mean, sorry, the player tag in order to pick up things.
And in here we said the pickup true,
so we don't pick up twice.
And in here we should actually increase
the amount of coins that we
have and that is going to be a challenge.
You. So add the coin and playing a sound effect.
So first of all, create
the level manager and add the coins to it.
Dicey create, I meant get the level manager and the coins
to it and play the sound effects
when we pick up the coins,
you can choose whatever sound the fracture like.
Maybe you can even go and get your own,
find some if I would then provide you
with an so that out of the way,
pause the video right now and go to the challenge.
Okay, welcome back.
So in here we are going to get
the level manager, or sorry,
not the level manager, the game manager,
but the game manager is not an instance.
So in here we're going to create
a public static Game Manager.
We can find the object,
that's something we could have done,
but because we are going to
maybe access at multiple times,
I believe having an instance is better.
So in here, I'm going to set the awake
and instance equals this.
Save that.
Let's remove the start and update for now.
If we need them, we will create them later on.
Save that back in the pickup.
Game.
Manager.
Dot instance, dot, add coin or get coins, get bitcoins.
And how much do we want?
It's the coin amount.
Save that, and now we want to play the audio.
So AudioManager, you manager
the instance that play as
a fax and which sound effect do we want to play?
We could create it in here.
Yeah, sure, let's do it.
So the sandbox to play.
There we go.
As a fax to play, save that.
And back in our game.
Let's see what we have in here.
And the Audio Manager,
where is it the Audio Manager?
And what do we have
the explosion, enemy rifles, shotguns,
typer player getting hit, pistol shot, explosion.
Let's add the Explosion. Sure. Why not?
Because I can't find any common pickup.
You can add anything that you want.
It's just need some kind of metal.
Actually, I think I did add
something in here but we didn't add it.
Anyways, let's use the explosion just for fun.
Anyways, element two.
So the two save that, run the game.
And now when we get to the coin,
we should hear nothing at all because in here,
no, there is no error there.
Ok?
No.
But didn't even destroy itself.
So there is a problem.
And get component.
Pick up layer has not been picked up.
Let's see, because this must be simple.
Let's wait for this maybe timer 0.5.
Nope, not working at all.
So let's see what the problem is.
0, okay, come back.
So we create an On Trigger Enter.
That's fine, but we don't have a trigger to trigger this.
So we need to add a box collider or circular
collider 2D and make it a trigger.
So the circle collider,
I believe, is extremely huge.
No, where is it?
Although it's exactly on the coin, That's excellent.
Save that, run the game.
Now we should unmute the music.
And you could hear a faint sound of
the explosion in the background. I could hear it.
I hope you could have heard it.
We go to the prefabs,
we go to the pickups and we said the Bitcoin right here.
So I hope you enjoy it.
Make sure to commit your changes,
make sure to leave a review.
It helped me out a lot and I'll see
you in the next video.