Game Advanced Prototype 3
GCC Academy
Hello
I am Youngho Lee, and I am in charge of the shooting game production course
In this unit, we will learn about prototype 3
The learning content is about making bullet movement
making bullet firing
and making enemy movement
Making Bullet Movement
Let's create a bullet movement
First, let's create bullets
and then implement the shape of the bullets flying
Let's go to Unity
and create a bullet game object first
In the hierarchy, press +
and click Cube in 3D Object
Let's put Bullet in the name
Let's put Bullet
and press Reset in Transform for the position
It's here
and I'll make the size smaller
than the player
I'll put it like this
And since this bullet actually needs to move
so, let's create a script
In the Project window, in the Scripts folder
press + and put C# Script
Let's put Bullet in the name
Once the Bullet script is created
drag and drop it onto the Bullet game object
like this
Now, let's define
this bullet's roles in the script
What does this bullet want to do?
It's going to keep moving upward
That's what the bullet does
So, this bullet
This bullet class itself
is made up of properties or functions
What properties are needed
to perform this sentence?
In the end, you'll need to keep
asking the planner
What information is needed when you try to implement this
in this sentence?
That's what you can talk about with the necessary properties
At this point, you might need the movement speed
You need to tell us the movement speed
so that we can move according to the planner's intention
And we've set the movement speed
but it would be good if the planner
could directly modify this part
Okay, so for the movement speed
let's put public float speed here
and set it to 10
The player moved at a speed of 5, right?
If you go to PlayerMove
you can see it's moving at a speed 5
But what about Bullet?
I'll process it to move at 10
And since this guy wants to keep moving upward
we need to
implement this in either
Start or Update
Since this content needs to keep moving
we'll need to put it in Update
Then, let's break this sentence down
into a little more detail
What is this sentence ultimately trying to do?
It wants to move
To move, you need something
That is, you need a direction
In other words, you need to find a direction
to move in that direction
If you look at the priorities
this is how the priorities should be
Find the direction first, and then move in that direction
Here, what can we see
as the direction?
Let's put direction in Vector3
dir
This would be Up in Vector3
The movement formula is P=P0+vt
It's like this
So let's put it in like this
As we did before, what happens to P0?
The position of the transform is P0
Next, vt is dir times
the size and we'll put in Speed
which is the property
Then, if you do * Time.deltaTime
you'll get vt, right?
And if you put this value of P=P0+vt in Vector3
and finally put it in the position of the transform
the content will be complete
You can break it down like this and write it
but if you write it as one sentence, it's like this: P0
Then + vt, you can write it like this
If you combine these sentences into one, it'll be the same
This much will be P0 and vt
So you can see that this sentence and this sentence are the same
Let's save it and check it
Bullet already has a Bullet (Script) attached to it
When you press the play button
this Bullet will fly up
Here, there is something we need to differentiate
Speed ​​is currently exposed in Bullet
Player doesn't
In other words, if the planner wants to modify
these values continuously
Player has to ask the programmer
to modify this number
Then, the Player has to keep
modifying this number while working
This is a very bad way
It would be better to allow the planner
to modify his components
So, I think it would be good to make this number
5 like Bullet in Player
and use this speed value like this
How did I do that?
I added a property called
public float speed to PlayerMove
I processed this property value speed variable
to be used in vt
Then, when we save and go
Player's speed 5 is exposed like this
So we can change this value
This way, the planner can modify it easily
I showed you how to do this
without asking the programmer
Bullet is also exposed like this
So when you play, the bullet goes up
the Player moves according to the speed
and this part becomes the motion
Making a Bullet Launcher
This time, let's try firing a bullet
If you pull the trigger
these processes will occur
If you look at it, you will pull the trigger like this
Then, there are two ways
As seen on this screen, first
I'll call the bullet factory
You will place an order at the factory
So you will receive the bullet
and fire it
The second is that the bullet will come out like this
but even if you look at this bullet, there are a lot of bullets in the magazine
So, the structure is to
take bullets from the magazine and fire them bang bang bang
every time you pull the trigger
The second is to fire bullets from the magazine
Of course, we will fire bullets from the magazine
but the bullets in the magazine
have to be produced from the bullet factory here
In actual practice, this structure
is used in which the factory directly produces bullets
Here, practice is what we are talking about in the game
Here, we will look at some information related to the factory
Later on, we will try putting bullets
in the magazine
It's a little ignorant, but we're going to do this
every time we pull the trigger
When we pull the trigger, we will call the bullet factory
At this time, this factory is smoking
but stopped, and at this time
Mr. Kim is sleeping on a cot
Mr. Kim is sleeping here
Ring ring ring
Then Mr. Kim has to jump out of his sleep
So he says, "Hello!" and answers the phone
Then I say urgently
I'll call him Mr. Kim
Hey, Mr. Kim, I just pulled the trigger
so make me a bullet quickly
Then Mr. Kim says, "Okay, I understand,"
and immediately lowers the lever and starts the factory
Then, since the factory isn't running
the conveyor belt has to move first
If there's a container for materials
he puts lead and gunpowder in it
and Mr. Kim works hard
Then how? He cuts the lead
makes all the gunpowder, and a bullet comes out
A bullet like this comes out
So, how do we do this bullet?
Here, let's load bullets onto the truck
Like this, we load bullets onto the truck
Then he'll come along this road in the truck
Then he'll give me a bullet
Then I'll shoot the bullet here, bang!
It'll fly
But I'm not going to shoot just once like this, and shoot three times
Then what will happen?
I'll have to make a phone call and wake up Mr. Kim
If I asked Mr. Kim to make a bullet and shoot three times
I'll have to say Mr. Kim three times
Then, every time, Kim gets up
lowers the lever, starts the factory
puts in the lead, adds gunpowder, shaves it
makes a bullet, gets on the truck, and delivers it to me
And whenever I call Mr. Kim
he'll have to keep repeating this process
What if you were to
burst and shoot in a way that
we usually call a machine gun?
It'll be like Mr. Kiiiiiim
Then, Mr. Kim would continue
to do this at high speed
This would be very inefficient
It would be inefficient
If you were to make one bullet in this process
this would inevitably happen
If you were to improve this process
what part would you improve
to continuously shoot bullets quickly?
Some might think
Oh, we should improve the roads a bit
You might think that way
Then delivery would be faster, so that would be okay
But you could also think this way
This is a bullet factory
Since it only produces one bullet, isn't that a waste?
And if this factory stops and starts
It would be overloaded
So if you just turn on the factory
and make a thousand bullets at once
the factory would be really fast when making those things
What if you make them?
Then, you can just load them up and run
Then, I can receive it without having to order from the factory anymore
and shoot as many bullets as I want
In other words, I can request this part all at once
We call this batching
We call it batch processing
In reality, this process also happens, Batch
Of course, this is the case in reality
and this same process occurs on the computer side
when doing some processing
If we organize the terms
this factory, in our computer software
we can call it a file in computer science
And the bullet created from this factory file
is called an instance
The bullet is created like this, right?
I have to get an instance like this
There is something that gets it like this
This passage is called a Stream
It is Stream, a
It is called a stream
Then, when I read the file
and receive the instance through the Stream
I only send the bullet
What if we navigated to an image
and double-click to open it?
You double-click the file
and ask it to open it
That's a double-click
When the file is opened
memory data comes in through a stream
To display it on the screen, we need an instance
We take it and print pixels on the screen
That's how it appears on the screen
You can think of this bullet as the image you see on the screen
This is a series of processes
and the process of opening this file is ultimately slow
When you open the file
you can create
many of them at once
That's called batching
Or, what can we say on our side?
What's your labor pool?
If you have some leftovers, can you give me some? Can you lend me some?
They can say like this
That's called a labor pool
That's when we use the term pool
In this case, bullets, game objects
creating these objects
so that there are extra ones is called a Pool
and we add an Object in front of it
That's called Object Pool
In other words, to improve this speed
the task of creating multiple bullets
and multiple objects in advance
is called an object pool
Opening this file is the same structure as a network server
that is, when you access various websites such as Naver, Kakao
or Google
When you access a portal site
When you connect
to connect to their network
this Connection happens
The users make the connection
This is the same
I am a user who hits the website
Then, a connection is made here
This is the same as opening a file and doing this work
When you send and receive data
and this work continues every time you access it
it will be slow
If there are 1 million users, it will be very slow
If there are 10 million users
the server may even go down
Since it is slow at this time
opening a file is a very slow task
Opening a network connection is a slow task
So it would be good to have a connection pool
That is why it is called a connection pool
There are a series of computer science terms like this
So when we fire our bullets
we will first make them directly
in the factory in the prototype
Later, in the beta version, we will use the object pool
to improve the speed in advance
and work for it
First, let's try making these bullets
in the factory
In Visual Studio, there is a Bullet section, right?
This is a bullet that has already been made
So, we need to fire that bullet
So the firing will be done by the Player
Since the Player pulls the trigger
there is a script for moving the Player
so now let's create a script for firing and paste it
In the Project window, click +, and in C#
this time, let's enter PlayerFire
PlayerFire will be created like this
If we drag and drop this onto
our Player game object like this
the PlayerFire script will be created
Let's double-click and open it
This is what PlayerFire does
We want to create a bullet when the user presses the fire button
We'll do this
So, what properties are needed here?
The planner needs to tell you
There can be multiple bullet factories
When making bullets, you said that they are made at bullet factories
Then, when there are multiple bullet factories
we need the address of the bullet factory
to know which bullet factory to make them at
So we need a bullet factory here
And once the bullets are made
where will they be placed and fired?
You can't fire the bullets from your hand
You need to decide whether to fire them from the wing or the muzzle
You might need this
So you might need a muzzle
Let's add these two
as required properties of the class
First, let's make a bullet factory
If you look at the bullet factory
you can see a bullet already made here
How do you make a bullet factory
to make this bullet? You can make it like this
If you look, I'll make another folder in Assets
Press + and select Folder
I'll put it under Prefabs
I'll make a folder called Prefabs here
This bullet factory
is called a file on our side
I want this bullet to become a file
Then, we can open this file every time
and create an instance of this bullet
So, what does it look like conceptually?
This thing in the Hierarchy is called an instance
Everything that goes up in the Hierarchy scene
is called an instance
It's an instance
It's already been created and is in memory
However, it hasn't been
saved to the hard disk yet
The space where it's saved to the hard disk is this project window
In other words, we call things saved to the hard disk files
So, if I want this instance here to be a file
where should it be?
If it's in the project window, it'll be a file
Conceptually, this is how Unity
uses this UX
If you grab a Bullet and drag and drop it
into the Prefabs folder
a bullet Prefabs named Bullet will be created
This is a file
In Unity, we call these
Prefabs
Game objects that have become files
What do you call these?
Prefabs
So what about the color of this bullet?
It's blue
It turned into blue
Since this bullet was created here
I'm going to make it so that it's only created
when the user presses the fire button
You can delete this one
Why? Because it's already a file
What? If you want to use it again?
You can drag and drop it
here or there
You can create as many bullets as you want
as instances
If you have a file, you can open it
to continue creating bullets here
But when do you create this?
When the user presses the fire button
This becomes a bullet factory
What is this?
The game object has become a file
It has become an asset
So, we can declare the bullet factory like this
How about putting it as a property
public GameObject bulletFactory?
It's for receiving the bullet factory, it's a variable
Why is it a game object?
Bullet factory, what was the prefab we were making in the first place?
It was a game object
If you look at Player
Bullet Factory appears in Player Fire
and you can drag and drop this Bullet
into it like this
That means the bullet factory is connected
You have to pay attention to the name
This isn't a bullet, what is it?
It's a bullet factory
Next, how do we make the muzzle?
Let's put public GameObject
firePosition here
Then, we created the muzzle
We don't have a muzzle yet
Right, let's make a muzzle
Let's see, I think the muzzle
should be around this position on this Player
If it has wings later
I want it to shoot two shots
Then I can put it here, right?
So that the bullet comes out here
Since it doesn't have that right now
let's process it
so the bullet comes out around this part
So, if you select Player
press + here and Create Empty
It will go up to this level in the same Hierarchy structure
We can drag and drop it
to Player like this, but this method also exists
If you right-click on Player
you can see Create Empty
or 3D Object here
Let's click Create Empty here
Then, it will be registered as a Player child
The location will be registered at 0, 0
Let's name it FirePosition
For the muzzle
Why did I set it to Empty?
It doesn't need to be visible, so I made it like this
Since it doesn't need to be visible, only the Transform is there
It only has this that can adjust the location, rotation angle, and size
I'll grab this FirePosition
and put it here like this
Then, the bullet will come out from this part
So, if you select Player again
you can see that I put FirePosition here
Let's drag and drop
FirePosition here
Then, FirePosition is assigned
What if there is no public?
If there is no public
if you go and look, FirePosition is gone
Why is that?
Only this public can be exposed to the outside
So you have to attach it like this, public
If you don't use anything
the default access modifier is Private
So I exposed bulletFactory and firePosition
Now, let's implement this part
to create bullets
when the user presses the fire button
These sentences must be placed in a function
The functions we know are either Start or Update
There is only one of these two
Even if you create your own function
you must put
Start or Update in the function call
So where should that sentence be implemented?
If the call is made directly from Update
to Start, it will be a bullet once when it is born
And it may not even be possible to press the fire button
So, let's put it in Update
so that it can continuously create bullets
whenever the user presses the fire button during its life
To do this, the ultimate goal
is to fire bullets, right?
It's to create bullets, right?
So, what do you need to fire bullets?
You need bullets
You need bullets to fire bullets
And here's the question
Why do you suddenly create bullets? According to this sentence
since the user presses the fire button
there are three things
the user presses the fire button, a bullet is created
and the bullet is fired
Strictly speaking, firing a bullet
means that when we create a bullet, we've already
set it to go up
We just need to decide where the bullet will come out
So, if we set the location like this
If you make a bullet and set the location
the bullet will come out from that location
So, if we look at it in order, the most important flow is that
the user presses the fire button
to create a bullet and set the location
of the bullet
So, if the user presses the fire button
we can see this if the user
presses the fire button
The grammar used in the C# language then
is called if
If the user's input is processed
we said that the Input class processes it
Now, if we do ., among the properties or functions
we'll use the function
function GetButtonDown
It means button is pressed
Then there's also something that was pressed and then released, right?
Then there's ButtonUp
If you look here, Down means it was pressed, and Up means it was released
Then what's being kept pressed?
It's doing GetButton
This uses GetButton when it is
being kept pressed
Since we will use the exact moment of pressing
we'll use GetButtonDown
Here, Fire1 means clicking the left mouse button
or the left Ctrl button
At this time, you can process the following contents
to be implemented
Fire1 is the Input Manager
in Project Settings
of the Edit menu of Unity
There is an Input Manager in Project Settings
Fire1 is set like this
So first, if the user presses the fire button
this part will be it
If this is true, the button was pressed
so that you can create a bullet
How do you create a bullet in Unity?
Instantiate, Mr. Kim, create a bullet
in the bullet factory
and give it to me
It is called a factory method called Instantiate
Factory function
It automatically creates everything in this
Giving it to me
means creating a bullet in the bullet factory
Instantiate, you can put a bullet factory here
bulletFactory, if you put a bullet factory in
it will create a bullet
and it is just like a game object, right?
If you put any of these game objects in
It will clone it and create it
This is just a function
If you made one for me like this
I could store it in a variable and use it
when I set the position and do things like that
I could do this GameObject bullet
This here is a bullet factory
and what is this?
This is a file, and this is called an instance
Since the instance from here is stored here
you can think of this as an instance
How do you set
the position of the bullet itself?
If you say bullet., you can draw a circle
among your properties or functions
Who has the position here?
Transform has it, in the game object
And if you say transform., what is the position
among the properties or functions? Position
Where are we going to set the position of this bullet?
This part of the muzzle that we put here
is this muzzle firePosition
If you put this transform.position
it will be assigned to the muzzle position
Okay? Let's save it
and go and press the play button
Then, bang bang bang bang, the bullet will come out
It will come out even if you move and shoot
What do you think? You can see that it comes out from that location
depending on the position of the muzzle
Should I put it here?
Bang bang bang bang, it will come out from that location
Strangely enough, I'll turn off the play button
So, the position of this muzzle is here, but where does it go?
If I turn it off, it goes back to the original
When we press the play button
it doesn't get reflected if we change
some values ​​or something
Why? These are saved in a file
but when there is a play button
it is not saved in a file
So, this exists only temporarily
while playing the data
Then, if you want these saved in this way to be saved
you will have to learn the concept of saving later
We will work on that in the beta version
I have tried firing bullets like this
Making Enemy Movement
Then, let's try making an enemy move
First, to move an enemy, you need an enemy
So, let's make an enemy first
In Hierarchy, press + and select Cube from 3D Object
I'll call it Enemy
I don't know if you noticed
but we're doing the same process from the player
to the bullets to the Enemy
What do you do first?
Make a game object
In Hierarchy, create a cube
create a script, assign the script
then code
and continue creating content with this flow
The most difficult part of creating content with Unity is that
you can learn each function individually
However, you may have difficulty figuring out
how to start and create content
How do you do that?
Just follow this
What do you do first?
Create a game object, a cube
create a script for it, assign it
Assign the script only to the game object
that needs control
You can continue to create characters
with this flow
Now that the Enemy has been created
I will assign a script
Before that, I will first set the transform position to 0, 0, 0
and I will put it on top like this
So, I'm going to create an enemy
that falls down
In the Enemy Scripts
I will put "Enemy" as the name
in the C# Script, like this
Then, the Enemy will be created
and I'll drag and drop it
onto the Enemy game object
Now, let's edit the script
Here's the Enemy script
You can click here
or double-click here to open it
When the Visual Studio
for editing Enemy opens like this
what I want to do here is
if the bullet keeps going up
I want the Enemy to keep moving down
What do we need here?
It's the movement speed
So, public float speed
Let's set this to the same speed as the Player
And this content that we want to keep moving down
we have to keep moving
so we'll go into Update
It's the same, right? It finds the direction and moves in that direction
So, this puts dir
in Vector3, and what's the direction?
If you put Down in Vector3, it means down
And then we want to move
I said that P=P0+vt can be used at once
What about the position of the transform?
transform.position = dir * speed * Time.deltaTime
You can do this, but how about this?
t simply updates the current position
It's just P=vt
For this to function normally, P=P0+
you can do it like this
What do you think? P0+vt
But since this is also a language, it can be abbreviated
Just like we say teacher as T
and food waste as FW
This can also be abbreviated like this
If we do this, it becomes P=P0+vt
Likewise, if we go to Bullet
it is also like this
We can abbreviate this part
In Bullet, we can write += like this
Right? So in Enemy or bullet
or P=P0+vt, you can do the transformation
by adding like this
Save it
If you press the play button, you can create
an enemy that comes down
You can create an enemy that comes down like this
Let's use vectors a little more
and write code to make this enemy move
toward the player
We can use vector subtraction, right?
So what we want to do this time is not to go down
but to continue
moving towards the target
Then, what else do we need besides the required movement speed?
We need a target
This target is public
The target is a player in the world
This is a game object
So, let's put GameObject here
Okay, so you can put public GameObject followed by the target
Ultimately, we need
not just the game object but also the location of this target
Who has the location?
The one that has the location of the game object
is Transform
So we only need to know this player's legs
Where are the legs, right?
Here is instructor Lee Young-ho
There is instructor Lee Young-ho, but if I don't know the entire
but the bridge's current location
I can monitor the bridge
and get its location
So, I only need to know about this component called Transform
So I can put GameObject here
but I can also put Transform like this
I just need to remember
this Enemy's Transform
So if I save it like this
and go to Enemy, the target will be exposed
here is Transform here
and I will show you an important concept here
The player here is a game object
I want the Enemy to follow the game object
To be clear
this Transform in Player
needs to go into Enemy
But you can put it like this
If I grab the player, grab the game object
and put it into this target
it wants to Transform
so I put the game object called Player
Then, the Player's Transform
is automatically assigned like this
Unity has such a great
User Experience
It even automatically assigns the player transform
So, we set the target for the enemy
Then, since we want to keep moving towards the target
the player will be in here
Then, let's find the direction
to go towards this target
Not down, now it's the target
How do we find the direction towards the target?
Target-Me, one of the properties in the target is position
We need the position
-Me, my position
can be written as transform.position
Then, Target-Me
can find the vector
that I'm heading toward the target
But we can't just use the entire path
How? We set the size of this vector like this
and move at my speed
This act of making the size of the vector 1
is called Normalize
So, if we call the function Normalize
for this direction
what happens to the size of this direction we found?
We make it 1
If we do this, there will be no change in that direction
Let's save it like this and go back and look
Let's press the play button
Then, the enemy will continue to follow me
as I move
Do you see? You can make an enemy
that follows the player like this
Then, it will continue to follow me like this
but I will change it
so that it only follows me once when I am born
Once when I am born
I want to find the direction in which I was born
and keep moving in that direction
I want to keep moving in that direction
Instead of continuing to move towards the target
What happens then?
I need to find the direction once when I am born
It's not something you keep looking for as you live
How do you look for it?
Since the time of birth is the Start, let's do it here
But we can't use the dir here
This variable in Start
is called a local variable
In Update, we can't access this local variable
in another function
Then where should I put it so that I can access it?
You have to register it globally as an attribute
to use it
So let's put the dir of the Vector here
in the attribute section like this
I'll process them like this so they use
the dir I registered here
Then, this one has the lights on, right?
They'll all be the same
So when it's born, it gets a direction once
and wants to keep moving in that direction
This one gets a direction when it's born
It wants to keep moving
So let's save it, and when it's born, it gets it once
and wants to keep moving in that direction
I'll go and try it
Then, I'll put it on the side like this so it's noticeable
When I press the play button, even if I dodge
this one will keep moving in the direction
it initially got
This is how the Enemy was created
If the enemy is made like this
some guys will come down
and some will go towards the target
which may be necessary
So, let's implement it like this
to set it randomly
So randomly, with a 30% probability
some guys will go towards the target
and others will just go down
Then, if they all move towards the target unconditionally
it will be difficult for the player
So let's give them this kind of variation
Then, when they are born, the content will be entered
when they find this direction
How are we going to do it?
Find the direction towards the target with a 30% probability
otherwise, if it's outside of 30%
Just set the direction down
Let's put it like this
Then, we can get a 30% probability like this
First, let's get the probability
Let's put in int for the probability
Let's put in percent
If you look at Random, there's something called Range
There's also RandomRange
but it's not used here
Let's put it as Range
Let's put in 1 to 10 here
So, what does this Range look like?
It says maxExclusive
If you go inside, it looks like this
It goes int and works
So we're going to use it here
Let's get percent from 1 to 10
Then how do we say that this has a 30% probability?
If it's less than 3, right? Then it's 30%
If it's greater than 3? It's a different probability
So the probability of 30% is it(percent <= 3)
It includes 3, right? Because it's 1,2,3
Then what do we do?
In the direction of the target like this
Let's get it in the direction of the target
This part is the 30% probability
Otherwise, what do we do? Since we just did it down
we did else like this, so it's just down
So you can do this dir = Vector3.down
You can do like this
Should we save it and go and take a look?
If you press the play button
you can see that this moves down or towards the target
with a 30% probability
We've learned about the enemy's movement up to here
Let's summarize what we learned in this section
The first learning content
was implementing bullet movement
We created a Bullet game object and wrote a C# script
to move it up
The second learning content was implementing shooting bullets
We created Bullet Prefabs
and used the Player Fire script
to fire bullets
when the user presses the fire button
The last learning content was creating enemy movement
We created an enemy object
and wrote a script to move it down
Thank you for your hard work
Create a bullet movement Create a bullet and set its position
Create [+] - [3D Object] - [Cube] in the hierarchy and rename it to Bullet Change the position and size of the bullet in the Bullet's Transform
Create and assign Bullet script Create [Scripts] - [+] - [C# Script] in the project window and rename it to Bullet
Drag and drop the Bullet script to the Bullet game object's component
Implement Bullet movement script Create a speed variable with public access modifier so that it is exposed on the Unity editor
Add implementation to the Update function so that it is continuously called Find the up direction and implement the movement part using the movement formula P = P0 + vt
Create a bullet launcher Create and assign a PlayerFire script Create [+] - [C# Script] in the Project window and rename it to PlayerFire
Drag and drop the PlayerFire script as a component of the Player game object Create and assign Bullet Prefabs
Create a folder in the Project window and rename it to Prefabs Drag and drop the Bullet object in the hierarchy to the Prefabs folder in the Project window
Remove Bullet from the scene and assign Bullet Prefabs to the Bullet Factory property of PlayerFire Create a gun barrel and assign properties
Select the Player object, right-click, select Create Empty, and rename the empty game object registered as a child to FirePosition
Assign the FirePosition object to the Player's PlayerFire script
Processing bullet firing input We need to produce a bullet every time the fire button is pressed, so input it in the Update function
Use the GetButtonDown function that returns True when the button is pressed When the left mouse or left Ctrl button is clicked, input processing is 'Fire1'
When bulletFactory is input as an argument to the Instantiate function, a bullet is generated
Assign the position of the muzzle, firePosition, declared as a property to the created bullet object
Enemy Movement Production Create Enemy object and assign script Create [+] - [3D Object] - [Cube] in the hierarchy and rename it to Enemy
Create [Scripts folder] - [+] - [C# Script] in the project window and rename it to Enemy Drag and drop the Enemy script to the Enemy game object's component
Write movement code Declare the movement speed property, find the direction, and implement the code with the movement formula