Game Advanced Edition Alpha Type Version 1
GCC Academy
Hi
This is Lee Yongho, instructor of the shooting game development course
In this chapter, we will learn about
the first alpha version
The first topic of learning is upgrading the Player
Enemy, and Bullet to the alpha version
Next, we will add explosion effects
and learn how to control these effects
Next, we will create a background that scrolls to the right
We will learn how to play sounds next
Upgrading the Player, Enemy, and Bullet to the alpha version
Let's start by upgrading the Player to the alpha version
Upgrading the Player to the alpha version means that
previously, the player was created using a cube-based model
Let's go through the process of upgrading the Player
to the alpha version using actual assets and data
we will need to use the Asset Store
in Unity to do just that
Let's open the Asset Store in Unity
Clicking on Asset Store in the Window menu will open
a web browser and take you to the Asset Store page
In the Asset Store's search section
you can find Awesome Cartoon Airplanes
The Awesome Cartoon Airplanes asset will be like this
Clicking on it will take you to the Awesome Cartoon Airplanes page
Yes, you can download this asset
Click the Add to My Assets button there
then it will change like this, click Open in Unity
Once you click the button Unity will open and the Package Manager will appear
Then in Package Manager
You can download the Awesome Cartoon Airplanes
Let's click download
After some time, the download will complete, very quick
Now from here, click the Import button
If you click import button
You will get a new window called Import Unity Package
From here, we can choose assets we want
and then add to the project
right now, all of these are selected
Since we want everything, have these selected
and click import
Click
Now, by importing these assets, they will be added to your Unity project
and you can start using them in your scene and game
If you see here in the Project window
Here, can you see Awesome Cartoon?
In this window, we can see the assets package
we've downloaded has been added here
Now you can close the package manager
In here, if you look at Awesome Cartoon Airplanes folder
The ones we will be using are in the folder called Airplanes
This package is in the folder of Airplanes
For the first player
Let's use airplane number 1
The question is, after selecting Airplane 1
how would we actually implement it to player 1
Let's select Airplane 1 and set it as a child of Airplanes and register it like this
Them, you will get a player with a model like this
After registering, grab the model and rotate it by 90 degrees
You can change rotation value x to 180
Airplane 1's size is 0.25mm
Airplane 2 is also 0.25mm
Then, it will be as big as our Player model before
Like this, we've changed the size to 0.25mm
You can actually do this all at once
You can go to Scale property
Mouse click on this icon here
Now, the X button that previously had a line through it no longer has the slash
If we set this up, we can change Airplanes' options all at once
Let's put 1 in this box and then you will see everything change into 1
If you put 0.2, others will also change to 0.2
change values for scale option at once 0.2 or 0.25
0.2 value gives you a good enough
Next, what is responsible for the appearance of the player is
If you select it as gameObject
You can see this a white box implemented
Let's remove this factor select it as Player and on the right side
Here, the Mesh Renderer and the Cube, these are what directly handle the appearance of the player
I want to make the cube box that is responsible for the appearance invisible
Then, right-click on these two components and select the appropriate option
If you select Remove Component, it will remove it from the screen
Since the Cube is not actually needed, so for Mesh Filter, remove its component as well
Cube Mesh Filter will also disappear from the screen
The green outline around the object is currently visible though
How do we remove it?
This refers to the Box Collider
The area of the Box Collider is what represents that part
If I disable the checkbox, you'll notice that the color changes
The Box Collider is exactly that part
Now, the components responsible for the appearance are done
If you look below, you'll see that the Gizmos option is checked in the game window
To hide the Gizmos, you can uncheck this option
By doing this, you've successfully updated the player’s appearance
Now, let's press the play button
Let's check if the player is correctly applied and appears as expected
The propeller should be spinning, and the player should be able to move left, right, up, and down
You should be able to see that the shooting and other features are working correctly
Now, let's learn about upgrading
the Enemy to the alpha version
Let's go ahead and update the Enemy in the same way
Without downloading anything, let's use Plane 2, 3, or 4
to work on the Enemy update
I will use the second one to update the Enemy's appearance
The Enemy is not in the Hierarchy yet
so even if we want, we can't
drag and drop it right now
So, where is the Enemy?
The Enemy is not in Awesome Cartoon
if you look below, you'll find it in the Prefabs folder we created earlier
Enemy is right in there
How do you make it a child of the one here?
To enable editing for this prefab
you can double click on it
So when you double click it
the Hierarchy and Scene windows
will switch to edit mode
In the Awesome Cartoon Planes folder
there is a Prefabs folder as well
Drag Plane 2 from the Prefabs folder and drop it into the Enemy object
This is the result you get and same as before
Now, let's remove the Mesh Filter and Mesh Renderer components
from the Enemy object that we're currently using
Right click on the component and then Remove Component
Right click and then Remove Component for cube as well
Like so
Now, only Plane 2 will be visible
Then, where should it be facing?
This one shouldn't look up
like the player, looking up
Why is that so? this one is supposed to go down
Therefore, it should be set to face
the opposite direction of the player
So, you can set the rotation values and X to -180
and 180 for Y and Z
For X, since it's just rotating by 180 degrees
you can leave it as is
You can proceed with this setup without any issues
You should adjust the size to match the player’s size
This button, which looks like a lock, allows you to change the size for all axes at once
Click this button, then change the value of one axis to 0.2
This will adjust the size of all axes uniformly
Now, the entire setup for the Enemy is complete
The wings of the Enemy are sticking out like this
Even if everything is correct but you still want to remove it
there's the Box Collider on the Enemy
In the Box Collider, you can see options for Center and Size
The center is about where to set
the reference point based on this middle point
If you change the X value of the Center
the Box Collider will move horizontally, either to the left or right
I'll leave the Center at 0
and then I will try scaling it from the middle
Let's try increasing the X value in the Size section to make it larger
Let's switch to 2D mode to view the wings more clearly
That way, you'll be able to see it more clearly
Once it's roughly aligned like this, you can remove it as needed
Since it will eventually move downwards, the bullet won't collide with the tail
This should be enough to complete the setup
So that if it collides here
it will be destroyed
Now we want to implement these settings
How do we save this?
If you look at the right edge of the Scene window
you'll see that Auto Save is checked
It means it saves automatically
if this one is enabled
Since we saved automatically through the Prefab
all you need to do is click the Back button
and it will return you to the original Scene view
Since the Enemy has been properly updated in the Prefab
when you click Play, you should be able to see
Enemy's appearance in the game window
It has been updated like this
Since the Scene view looks strange
I'll go back and set it to the Back
Shall we place it so that the player is visible?
I'll set it up like this and continue working
So far, we've upgraded the Enemy
to the alpha version
Next, let's continue
and upgrade the Bullet
to the alpha version
Let's search for Rockets
Missiles and Bombs
to find the assets we'll use here
If you search for Rockets, Missiles
you'll see it at the right end of the search results
Then, just like before, you'll find a page where you can download this asset
When you click Open in Unity, the Package Manager will open again
In the Package Manager
you can download the asset you want
Let's click download
Once it's done, it didn't take long
Let's click that import button
In the Import Unity Package, click Import button
to bring every asset
it worked and in here
there's Orion Sky's asset
Rockets, Missiles and Bombs
Here, what we are going to use is
the assets inside the Prefabs folder
Which one we are going to use is
To match Player's color, in the Yellow
I'll use number 8 Rockets
So how did we upgrade it to the alpha version?
Just like the other one
we need to go to Prefabs folder
Click on the asset and go to the Prefabs folder
where you’ll find the Bullet
Double click the Bullet Prefab to open it
Then you'll get edit mode
The Yellow 8 that we selected earlier
Let's drag and drop
the Yellow 8 into the Bullet as a child
Click Reset on the Transform to reset
Then it appears
It might appear in an odd position because it's placed incorrectly
It's too big
I will scale it down overall
to about 0.15
Reset the Bullet's Transform as well
and then adjust it again as needed
I'll click Reset on the Bullet's Transform
to restore it to its original position
and then the size value would still be 0.15
this is the size of it
all good so far
Right now, the collider is way too big right now
And also, it's centered in the wrong position
there's unnecessary gap
Therefore, we need to adjust
the center point and for the collider
to fit the actual shape
First, let's remove the Cube that is used for the collider
Right click on the Mesh Renderer and Mesh Filter
then select Remove Component to delete them
Then only the collider area will remain
Next, let's reduce the X size of the Box Collider to better fit the Bullet
Like so
Let's try 0.5
0.5
0.45?
0.45 fits the most perfectly
Now, let's move the center upward appropriately
For the collider's center value
the Y value
Let's increase the Y value by 0.07
then we still have some gaps
Let's change Y value to 0.9
this should work fine
So, by processing it like this
when we select the Bullet
it should be around this size
Let's put 0.5 for size
I'll make slight adjustments for the Bullet to be perfectly sized
allowing it to fit with other objects as well
Now, the Bullet's Prefab has been properly set up and is working correctly
Now let's click Back button
And see what we've got through a test
Now, play
You can confirm that the bullet is firing correctly now
You can confirm that both the Enemy and Player
have been updated to the actual data we want to use
So, we've seen how to upgrade the Bullet
to the alpha version up to this point
Adding the explosion effect
This time, when we play, there are a lot of parts that feel a bit boring
So, let's add an explosion effect to make it more interesting
Right now, what we’re working on feels a bit plain
The bullets are firing and everything seems to be moving
but it still feels lacking in excitement
Exactly, to solve this, we will add an explosion effect
to enhance the impact and make it feel more satisfying
Let's use the Asset Store to find an explosion effect
Go to asset store page
Let's search for Cartoon FX Free here in the Asset Store
Search Cartoon FX Free
The one we will be using from here is
This one right here
the name is Cartoon FX Remaster Free
Click this
Click Open in Unity button
The Package Manager will open, and the download will begin
Once the download is complete, click the Import button
to open the Import Unity Package window
Let's Import it into Unity
Once it's done
it will be added to our Project window
This time, there’s quite a bit of content to import
A new window will appear like this as well
I will hide this window and click to close it
and also close the package manager window
Now, in the Package Manager, the button
for the downloaded asset will show JMO Assets
In JMO Assets
you'll find Demo Assets, and within that
there is a demo scene file
Do you see this Unity logo mark over here?
There is Unity mark icon
This is the Scene file
Let's double click on the Scene file
When you open it, you'll see this section that allows you to run
Let's click on play button
I'll increase the size of this window
There is some kind of arrow and there are numbers from 1 to 31
If I do a left mouse click
We can see the explosion effect on click
When you press the left or right arrow keys, it changes like this
The effect changes
There's also one with some flame
effects like this again
also like this
or like this
How should we make the plane to be destroyed
Wow, there's even a huge explosion!
You can select the ones you want from this list
If you look, right now
There's some kind of writing under the arrows and numbers
If you want to see where these are activated
you can open them like this to check
In the demo script, you will see a list
and one of them will be highlighted
If I click here
you'll notice that the items being used are
all grayed out and deactivated
You can see that it's only activated when I click, and that's when it becomes visible
Right now, it is using
CFX R3 Hit Light
Alternatively, if you look at what is being displayed right now
If you double-click on the object called Canvas and click on it
The screen will shift to the view where the Canvas is located
Then, I'll zoom in to take a closer look
Here, where is it?
Here is the name, CFX R3 Hit Light
We just need to locate this part and work with it
Then where is this thing, I said to look at demo script here
The one that appears when you click here
If you select that and right mouse click
If you right-click and scroll down
you'll see the option called Prefab
you can scroll down and enter it like this
When you want to take one of these
right click on it, since it is currently in Prefab state
I will turn off the play button
Then it is added as Prefab state
After right mouse click
and go to Prefab menu
There is an option called Open Asset in Content
Do you see it?
Click Select Asset
What happens? The link to
where the window is appears
It let us to jump there right away
For others as well, mouse right click
In Prefab, click Select Asset
Then you can go to the location where the Asset is
Do you see it?
The one we will be using among these
is the explosion effect
So let's use Assets that are
in the Explosion folder
And this Fire effect
or this other one
so that we also have some smoke
If you look, this one is the second one
Let's see what it looks like when we actually play
See how it's like
I think this one is pretty good
Compare between these two
After explosion, even the screen shakes
I like the first one
and the second one is also good
I will choose the one
that has smoke after explosion
How do we set the position?
Right mouse click on Prefab
find Select Asset
And then it will find its location
Let's use this one
To enable the effect
Let's adjust our script first
Let's open default Scene file
In the scene, Sample Scene
This is what we've been working with
Can't we use our Scene?
We can change the name
Or in the file, make a copy
by clicking Save As
in order to make use of it
However, there are rules to this
What kind of a rule?
This one must stay in the Asset Folder
It shouldn't stay outside the folder
Remember, that's the rule
You have to save this Scene file inside the Asset Folder
If we were to save it in this Scene
as Shooting Scene
Save it as Shooting Scene
You have to save it here
You shouldn't save it outside the Asset Folder
Save
Then we can see that there's a new scene called Shooting Scene
and if you double click
in the Hierarchy
Do you see a Scene file named Sample Scene?
When Shooting Scene opens
you’ll see that the window switches to Shooting Scene
or you can open multiple scenes when working
just like here
if you drag and drop the Sample Scene here
you can see the structure of Unity
where two scenes open at the same time
do you see it?
you can have two Scenes
at the same time
When I made a change up here, the change follows down there as well
Like this, you can have two scenes opened up
If you want to remove one
you can right mouse click on it
How?
Select Remove Scene
Unload Scene is to only disable it
How again?
If you click Remove Scene
you are removing the registered file
It won't remove any original data
so that's that
So, we are working
in the Shooting Scene
Where do we use the explosion effect then?
In the Script window, let's open Enemy Script
Then, we will have the effect process here
the reason we do that here is simple
Think about where the explosion effect should occur
Let's check this diagram
The collision we implemented
with Enemy, Player or Bullet
When colliding, the way they collide is
that Player and Enemy were able to collide
And one more, Enemy and Bullet
were made possible to collide each other
and Player and Bullet weren't allowed to collide each other
and between Enemies as well
We made these rules at a default setting level
So, in a way, if Player and Bullet cannot collide
who would be the common denominator between Player and Enemy?
Since the denominator comes down to Enemy
So if to say Enemies go Kamikaze on us
It can eliminate both the player and the bullets
So, how is the script set up?
collision handling is being processed in the Enemy script
Then, if the Enemy explodes when it collides
How about if both are eliminated
and an explosion effect is triggered when it collides?
We can display it as if everyone exploded
So, I will implement adding an explosion effect
In the Enemy script when it collides
The part we're referring to is located at the bottom
the OnCollisionEnter in the Enemy.cs
When Enemy collides with other object
what do we want to do?
We want to have explosion effect
want to trigger the explosion effect to be exact
Then where do we make Bullet?
we make it from the bulletFactory
And then where do we make Enemy?
Also from enemyFactory
Same should go with explosion, where?
Should be made from
Let's do it this way
Therefore, this one is in need of certain property
I will add the properties needed for the explosion at the top
At the top here, we need a explosionFactory
Write Public GameObject then explosionFactory
explosionFactory
So we've just declared an explosionFactory
If you go to Unity
Let's take a look at Enemy Prefab
If you go to the Inspector window on the right
The explosionFactory is exposed in the Enemy script
To this part, drag and drop
Explosion part from CFXS Prefab in JMOSS
to CFXS Prefab, drag Explosion part
and drop into explosionFactory
Then to the Asset we are going to utilize
will have explosionFactory registered
Since it's registered in here
Let's go down and try to trigger the explosion effect
Triggering explosion effect means
Eventually means, from bulletFactory or
explosionFactory, making explosion
Then, how do we make it happen
start with Instantiate
explosionFactory
put explosionFactory inside
if you do this, making explosion is done so far
then where is this?
It is placed at a default location
we have to set up its location, too
Where is this effect supposed to occur?
It has to occur where Enemy is
Therefore, start with GameObject explosion
make a variable, that saves Instance
and in the next line, who has the location of explosion?
transform dot position
In what location should we set it to?
Enemy will be the one exploding
Having the effect at Enemy's location will do
So, transform dot position
Right now, we are at Enemy
we are on a Enemy script
So since this is Enemy's transform position
The location we want is its own location
I have set it up so that the explosion effect occurs
at the Enemy's location
Let's save and comeback to Unity
Play
Then it moves like this
How's this?
Even the screen shakes
explosion effect occurring
How was screen shake effect created?
What that means is, in this explosion effect part, there is this script
If you look below this script, in the script called CFXR Effect
the very bottom, it’s being distributed
the effect is being processed
there is an option called Camera Shake
Inside this, it takes the Main Camera
handles everything on its own
and then updates the content
If we don't want any shaking effect
we simply can disable Camera Shake
After disabling, let's play to see what happens
Bang Bang Bang, how is it like?
there's only explosion but without camera shaking
you can see that it worked, it's done
We will proceed with this setting
Like so, we disabled
cameraShake
By doing this, we have applied the explosion effect scene
in the alpha version so far
Adding Background Playing Sound Effects
Next order of business is to add background image
The scene feels a bit dull having no background
The level of completion for this content is still not high at the moment
So, we will add a background this time to enhance it
If you look at things like bottles
you can often see tape with advertising slogans on them
These things are wrapped around the back like this
For example, it's wrapping a plastic sheet around it
And there are some writings in there
like the name of the drink like New Drink for example
How about we rotate the bottle
then what happens?
this sentence will be disappearing little by little
it will be on the other side
and a new sentence or content will be show up
because we rotated it
In other words, when we rotate a single sheet
where should we focus our view?
We should focus our view right on this part
Let's assume we fix our screen only on this part
How is it like then?
It might look like something is continuously moving, right?
You can script the screen in this way
with one sheet
Since we've been using Asset Store
might as well use it for this one as well
The most common and straightforward option here would be a space image
Space Star Field Backgrounds
When you search like this
You will find a file called Space Star Field Backgrounds
Among them, let's use the one
with space image should be easier than others
Since this one has white dots in the black background
When it's wrapped, it probably won't be very noticeable
Let's select this one
The price is FREE
This is the space image and I will use this one
Open in Unity
And download the image
Once the download is complete, click the Import button
and then click Import to add it to the project
After adding it, the file we just downloaded
should be under the StarfieldMaterials folder
If you look at this texture image
Here, you can see that there are
a lot of images we want to use
Right?
Click the plus button to create a new folder
and then place the Materials in that folder
Create a Materials folder
and then create a new Material inside that folder
In the Project window, click the plus button in the Materials folder
and you'll see the Material option in the center
Create it there
Let's name it Mat Background and add it
This material has been created
and now let's add the material
we want to use to it
Let's add the value to the Albedo property
If you look in the StarfieldMaterial
you'll see an option called SingleNeb
We will use something more noticeable
like option 7 from here
In the Materials folder, select it again
Then, for the Albedo section, click and hold on SingleNeb
and drag option 7 into the Albedo slot
By holding it there, it will be registered properly
Now, you can see the preview like this
If you don't want it to be displayed as a circle
we can change that
If you click different options
This part right here
If you click this, the shape of the object
This is cylinder, tube
and then square plain shape
It's like this
Sphere, cube and so on
we can switch between different shapes
Like this
Since we are having square background
Let's use this shape and see what it will look like
With this setup, let's go ahead and create
the background where it will be applied
In the Hierarchy, click the plus button
then go to 3D Object and add a Quad
Next, let's rename it to Background
The size is very small
So let's enlarge it a bit
To make it fill the screen more
Let's zoom in
As you stretch it horizontally
Take a look at it from the Game view
and you'll see it start to fill the screen
You can adjust it to fit reasonably well like this
Set the value to around 14, and 14 for X as well
Then, stretch the Y value to adjust it accordingly
Set the Y value to around 20
Now, when you look at it from the Main Camera's perspective
you can see that it fills the screen
You can confirm that it fits perfectly
inside the white outline of the Main Camera
You can see that it fits perfectly like this
Now, let's assign the material
we want to use to this
To assign the material, you can either
drag and drop it into the
Material section of the Mesh Renderer on the background
Alternatively, you can find the Mat Background
in the Materials folder that we've created and assign it from there
You can also drag and drop it like this to assign it
Alternatively, you can place it here
or anywhere else you'd like
If you place it conveniently, it will be applied like this
This means the background has been successfully applied
However, when we play
even though the background is added
what happens? It disappears, why?
It disappears because it collides with the Enemy
The reason this happens is because
Let me pull the player a bit closer
If you look at it this way, Let me slightly rotate it to the side
Then, you can see that the Background is overlapping halfway
So, they are set to collide with each other when they appear
So, the Enemy is colliding with the Background
That's why we have these problems
So, should we disable the collider then?
It would be fine, but the reason I'm working
in the regular 3D mode
instead of the 2D mode is
It's exactly for this convenience
For this convenience, how do we do it?
Simply select the background
and then just move it over here
So, how does it look? The background and the player
no longer overlap as we see it now
So, even when the Enemy appears, it will no longer overlap in this area
You can simply push it like this
Now, if you place it like this and play again
the background will remain visible, and the Enemy will appear
Like so, we finally have a background
So, the size and location of the Background have been fully applied
But since this Background is static
it seems like there's a lack of speed or movement
So, if you select the Background and go to the right
you can preview the material
that we're using in here
You can edit the Material here
or you can also modify it
in the material settings
There's an option called Offset
Let me change the Y value
When you look at the screen
Please check how the current screen is set up
You can see that the screen moves when I change the Y value, right?
It looks like the plane is constantly moving, right?
You can create this kind of effect
So, if you continuously
change the Offset in the code in real time
this part will animate, creating the feeling
that the player is moving
So, let's use a script to adjust
the Offset value for it
In the Scripts folder, click + and C#
Let's name it Background
As we have a background
Let's drag and drop the script
onto the Background GameObject
Now, the Background has been added here
double click
Go to Background
Since we need to change the Offset
in the material it's using
what we want to do here is scroll the background
At that time, the necessary property is
the Offset in the material, and it needs to be modified
in the Material it is using, so what does it need?
Material is the one
Then how fast it will scroll down
is another question
We need the scroll speed
We can achieve these utilizing two properties
Let's add the material
and then name it bgMaterial
I will name it like this
Background Material
Next, let's allow the designer to modify the scroll speed by making it public
public float and scrollSpeed We'll add this to it
Let's set the scroll speed to around 0.2 for this
then where do we get this Material from?
Instead of continuously checking during runtime
we'll make it find it once when the object is created and assign it here
So, we need to first get the Mesh Renderer
component attached to this object, because
What does Mesh Renderer have on this background?
The reason is that it holds Material
Mesh Renderer component has Material
So first, we need to get Mesh Renderer component
The method we could use here is
GetCoponent function
You just need to add the name of the component you want to retrieve here
So add in Mesh Renderer here
Then the function will get Mesh Renderer
Then we get this, which one do we render?
It would be Material
We can dynamically get the material we want to use
Now, we just need to scroll the Offset
Then, we want to gradually increase the Offset value now
and for this, we will be utilizing the formula for uniform motion
How about the direction? How does uniform motion work?
P = P0 + vt
v means velocity that we need
It's the vector
To offset with this formula
First, we need direction
What's the second?
simply make it move
Scroll eventually means to move
Because we scroll, move it in a given direction
So, let's state the direction
If you look at vector, there are only X and Y value
For offset, right?
Since this texture is an image, the image has no depth
Of course there are 3D textures
but this one uses a texture without depth
That's why it is using X and Y
So for this one, we use vector 2 instead of 3
For direction, simply put direction
Now, vector 2 toward where?
up
value needs to increase
For scroll, we use the formula stated earlier
which exist in bgMaterial
bgMaterial, why don't you give me your texture Offset
MainTexture's offset
What we want to do is to change Offset value
This directly become P
How do we make adding happen? P0 + vt
v equals direction * scrollSpeed
that gives us v
and then, put Time.deltaTime
P = P0+, this value means v
this one should be t
Like this, we've made a scroll
Save it
And then play this
We now see that it scrolls
Now the game looks more like it
with higher level of completeness
Now, let's add the sound effects
as the final step
Go to the Asset Store
Let's first download the Weapon Sound Pack from the Asset Store
Search for Weapon Soldier Sounds Pack in the Asset Store
Here, you'll see various gun related sound effects available
Let's click this one
Weapon Soldier Sounds Pack
Open it in Unity
You can download it from the Package Manager here
Once the download is complete, click the Import button
Let's import it into our project
It has been added to the project, and now let's import another one
This time, we will also import the explosion effects
Let's search for Grenade Sound FX now
This one is Free
Grenade Sound FX
Click this one
Also, open in Unity
Download it from the Package Manager
Also import project to add it to our project
So, for the bullet sound, it should play something like
bang! or pow! when the bullet is fired
So, let's add the sound to the bullet prefab
We'll set it up like this so that the bullet prefab
can play the sound
Let's choose which sound
we will use for the bullet
Now, open the Mental Dream asset
and you'll see the Soldier Sounds Pack
From there, let's take
the Fire sound and use it
So, select the bullet in the Prefab folder
then drag and drop the Fire sound
from the Soldier Sounds Pack like this
Then, the AudioSource component
which will allow us to control the sound
will be automatically added
and the AudioClip will be set to "Fire
This will do for us
Let's go and play
Let's see how it's implemented
The sound of firing bullets
is implemented very easily
For the explosion effect
you can play a boom sound when there's explosion
Now, let's go to the explosion effect
and work on adding the sound there as well
Since it might be hard to find the explosion effect directly
select this one at the Prefab
and then choose the Enemy
In the Enemy, you can find the part registered in the Explosion Factory
where the explosion effect is located
By clicking on it here, you can jump directly
to where it's located
Like this, you can jump directly
to the location of this Prefab
So, let's select this
We can simply drag and drop it here
To this explosion effect
Let's register the asset we want to use here
Since this is explosion effect
If you open the Grenade Sound FX
you'll see the grenade sound listed there
This one, grenade
Among these, if we grab the one that says Grenade 5 Shots
and drag and drop it here
Then it will be registered like this
Shall we play again?
Since it has been applied to the original Prefab file
if you play
How is it?
By simply moving with our cube
then assigning the player, enemy, bullets, background
and finally the sound were added into
doesn't the completeness increase suddenly?
We've added the explosion effect
If you want to add background sound to finish it off
For the background sound, it would be good for you
to find data that matches the feeling you're going for
In my case, I searched for metal under SS2
And then I found something like Eternity Djent Metal Scfi Horror Music Pack here
Select the Free version
I downloaded it from Unity
So, download it
When download is complete, import it
You could download them all but there are too many data
I will select this number 6, named loop
and Import this one to our project
worked right?
Then, let's register this and try using it in our project
It seems like you want to add the background sound
by dragging and dropping it into the background
So where is it?
If you open the Audio assets, you'll see the music
In this folder, you'll find the one we've added
Right over here
Drag and drop this file to add it
Then, this background sound for the title will play
continuously in an infinite loop
Finally, if you play it
you'll have created a plane game
with the metal sound as the background music
You can change musics
according to your preferences
With that, we've completed applying all the sounds
Let's summarize the content we've learned in this lesson
First, we upgraded the player, enemy
and bullets to the alpha version
We learned how to use the Asset Store for this purpose
and also how to modify Prefabs
Next, we learned how to implement explosion effects and play sounds
By adding these effects
we saw how they contribute to creating a more immersive game
We also created a background and implemented
scrolling by adjusting the material's offset
That's it for this lesson
Alpha version upgrade of the player, enemy, and bullets Alpha version upgrade of the player Replace the player's appearance with the actual modeling d
From the Asset Store, downloaded and added Awesome Cartoon Airplanes Drag and drop Plane1 from the Prefab folder and set it as a child of the Player
Select Plane1 under the Player, set the values of the Transform component Remove the Mesh Renderer and Mesh Filter components rendering the appearance
Alpha version upgrade of the enemy Replace the enemy's appearance with the actual modeling data used
Use the Plane2 Prefab from the AwesomeCartoonAirplanes of Prefabs folder for the enemy
Select the Plane2 Prefab from the Assets to AwesomeCartoonAirplanes to Prefabs, follow this path in the Project window
Drag Plane2 Prefabs and set it as a child of Enemy of Hierarchy Remove Mesh Filter and Mesh Renderer component of Enemy and Plane2
To exit editing the Enemy Prefab and return to the scene, select the Back button in the Hierarchy
Alpha version upgrade of the bullet Replace the bullet's appearance with the actual modeling data used
Search for Rockets, Missiles and Bombs, Cartoon Low Poly Pack in the Asset Store, download it, and add it to the project
Double click the Bullet Prefab in the Assets Project window to open the Prefab editing window
Set Rocket 08 Yellow Asset as a child of Bullet Select the Rocket 08 Yellow, and then change the Scale values in the Transform component
Remove the Mesh Filter and Mesh Renderer components from the Bullet game object Adjust Transform value and Boxcollider component value
Adding Explosion effect Add explosion effect when objects collide Search for Cartoon FX Free from the Asset Store, download and add it to project
Enable collision between Enemy and Player, and Enemy and Bullet, but disable collision between Player and Bullet Add explosion prefab property in Enem
Double click the Enemy Prefab in Assets Prefabs folder in project window open the Prefab editing window then add CFXR Explosion Smoke 2 Solo
Use HDR Assign the CFXR Explosion Smoke 2 Solo HDR Prefab to the Explosion Factory property
In Enemy.cs, create an explosion effect when the Enemy collides with another object and assign the explosion effect's position to the Enemy position
Adding background and play sound' Adding Scroll background From the Asset Store, search for Space Star Field Backgrounds and download to import
Create a folder in the Project window and rename it to Materials In the Materials folder, click the plus button, select Material,
and then rename it to Mat Background Select the Mat Background material and switch to the Inspector window to modify its properties
Then, assign SingleNeb 07 to the Albedo property In Hierarchy, create Quad and rename it to Background relocate Mat Background Material
So it doesn't overlap with Player after assigning Background gameObject's Mesh Renderer Component Materials property
Create a Background.cs file in the Scripts folder and then assign it to the Background game object In Background.cs, the necessary properties are Mate
Declare the two properties Assign Mat Background to Bg Material property For direction, Material Offset propert value is in the form of Vector 2
Implement it as Vector2.up The scroll is implemented using the motion equation P equals P0 plus vt on the mainTextureOffset property
Adding bullet sound From the Asset Store, search for Weapon Soldier Sounds pack and download to import In the Assets of Prefabs folder
Double click on Bullet to move to prefabs editing window drag and drop Fire sound from SoldierSoudnsPack Folder into Bullet Prefabs component
Adding explosion sound From the Asset Store, search for Grenade Sound FX and download to import CFXR Explosion Smoke 2 Solo HDR
Double click the explosion effect to open the Prefab editing window Add AudioSource Component to CFXR Explosion Smoke 2 Solo HDR object
Assign Grenade5Short file of Grenade folder to AudioClip adding BGM
From the Asset Store, search for Eternity Djent/Metal-Scfi-Horror Music Pack and download only the 06 God of darkness to import
Assign the Audio BGM clip to the AudioSource of the Background object, and then add 06 God of Darkness