Transcripts
1. 00 Promo: In this course, we learn
everything about creating ship that can go
through ocean or sea. So first, we create a ocean, and after that, we import
some files for our ship. And with that files, we create our ship, and we add some pontoon
to it so it will float on ocean. After that, we will use physics
force to go forward, go backward, go left, go right. And with all of these, we have animation for its blade. So when we go forward, the blade will rotate
and when we go backward, the blade will rotate
backwards, right? Next, or ship has a gun, so we can use it to
shoot at our enemy. With our gun, we limit it so it won't be able
to shoot at our ship. And we have a Zoom
capability as well, because our ship
can shoot far away. Next, we add some UI like cross hair and
health board to it. Next, we need some enemy. So for enemy, we will use
a artillery for our beach. So whenever our ship go in
front of these artilleries, they will shoot at our ship. And whenever they
shoot at our ship, it will have some physics
impulse added to our ship, and it can move our ship. Our anti ship gun has lots of
visual effects and sounds. So for example,
whenever it shoot the barrel will go
forward and backward. At the end, we create a
ship destruction, as well. So if our health reach zero, or ship will be destroyed. After that, whenever we shoot at our enemy or enemy
will be destroyed. So let's learn how
we can do that. Without any further
ado, let's begin.
2. 01 Create project and make it ready for Ship: For creating a ship game, we need to create a project. And for this project, I'm using ARIO Engine 5.5 0.3. And my recommendation
is to use this version that I'm using because in each new version of ARIO engine, they are changing the names. So if you are a beginner and you want to do
exactly as I'm doing, just stick with the
version that I'm using. So I did open up
ARIEL Engine 5.5 0.3, go to Games in here and
create a blank project. In here, we needed
to be in blueprint. We don't need the
starter content, and I want to name this ship. Right? And you can choose
where do you want to put your project by clicking in here and put it in whatever
folder that you want. After that, you can
say head create. No or project is open. At description of this video, there is a zip file that
is called ship dot Zep. Download it. Put it
on your desktop. You can just click
on it to open it, and there is a folder
inside it that you can just drag and drop it and
put it on your desktop, so it will be extracted. No, we need to import
it in ARIEL Engine. For doing that, go
to Content drawer, click on the content
folder, right click on it, and click on Showing
exxplorer and it will open up the content folder of our
project in Windows Explorer. And the only thing that we need to do we need to just drag and draw up this ship folder
inside this content folder. Don't put it anywhere else. Don't rename anything. Just do as I'm doing, right? Just with that, if you
go to ARIEL Engine, you can see the ship
folder is in here, but if you double click on
it, there is nothing there. The reason is we need
to restart our engine, so all of those
assets will reappear. But before doing that, I want
to change some settings. So for example, go to Edit, go to Editor preferences,
and in here, search for open and change the asset editor open location from default to main window. So whenever you open something, it will be open up up here. You can just close this next
thing that you want to do. We want to save this level, so head control is on your keyboard and save
it wherever you want. You can name your level, whatever you want, as well. But I want to just
name it new map, head save, and it will be saved. Now, if you go to
Content drawer, click on the content folder, you can see the level
is saved in here. Now, next thing
that we want to do, we want to go to Edit project
setting, and in here, go to maps and modes and change
the editorial starter map and game default map from open Word to new
map that we create. First time that we are doing it, it will change it to none, but again, click on it
and change it to New Map. Do it for both of
them like this, go to set the new map there. So whenever we
open Arial engine, it will open up
over level for us. Now, you can just close that. That's next thing
that you want to do. We want to go to
edit, go to plug in, and in here, search for water because you
want to have a ship. We need some, for
example, ocean, right? So we need to enable this
water login, enable it, and in here, head yes, and it will tell you you
need to restart REL engine. So click in here to
restart RILEngine. So all the assets and necessary plugin will be
there when it is open, right? Now when the project is
open for the first time, there is a error in here. It says collision
profile setting, do not include an entry. For fixing that, you can go at the end in here and click on this ad entry to default engine
INI. Just click in there. It will add it there
automatically. You don't need to worry about
it. You can just close it. Now, if you go to
content drawer, you can see if you go to ship, you can see the
assets folder there. We have lots of things. For example, if you go to SM, you can see a static
mesh in here. If you go to Vigilante
content, go to vehicle, go to West Ship, you can
see a ship in here as well. First thing that I want
to do inside this level, what I want to do, I want
to add ocean, right? Right now, there is no
water at all, right? So for doing that, we
need to go on here, click in here and search
for ocean, right? And drag and drop this
ocean wherever you want, inside or level, right? And now you can see,
because we put that there, there is a ocean
with a small island, and we can't see or open word. How we can fix that
we should click on Water body ocean,
go to DtilPanel, go down in here until you
reach the train, expand water, height map setting, and change the blemo from
Alpha blend to max. No, if you go close, you can see we can't
see any water. But if you bring this
up a little bit, you can see the water
will fill up a level. Now, you can see we have
a island at the middle. We can just click on it and
make it a smaller like this. Just click on it and
make it a smaller. We don't need it that much. Again, click on this point,
make this a smaller. If you want to have
island, you can do that. But I want ship to lots of
room to work with, right? No, with that, you
can see it small, and we can make it
smaller, as well. Sometimes our real engine crash, so make sure you save a lot. You can see. I'm making
this as small as possible. If you don't want this
hole to be in here, you can go to selection
mode, go to landscape. Make sure you save
everything because real engine crash a lot,
saving it, right? And no, in here, we can go to scalp, to a scalp and change the tools sernth to
one, so it will happen. And next, I want to change
the brush size a little bit. You can see it. No it's good. And we can bring these
parts up like this, right? That looks good, right? We have a small mountain at the middle of our
island in here, and we can put some
sp inside this ocean. So next thing, let's
just go back to selection mode and
we have our ocean. No, there is a warning in here that you can
just click in here. It's some water body
or not up to date. You can just click
on Mark dirty to get rid of that warning
if you have that warning. No, we are ready to
create a ship blueprint. So make sure you
save everything, and you can just close
this plug in folder. Now, we are ready. Let's begin.
3. 02 Ship blueprint: Now that we have a ocean, we need to create a ship. Let's see how we can do that. For doing that, I want
to go to Content drawer, go to Ship folder in here, right click, create a new folder and I want to call
it Blueprints. So all of our blueprints
will be here. Right click in here,
create a blueprint class. This time, I want to
create a type of pawn, so we can be possessed and receive input from
a controller, right? So click on Pawn and I want
to call it BP Shep, right? I'll click on it to open it. Now in here, what we
want to do first, we want to add or ship. But if you go to
assets, you can see, we have a skeletal mesh, right? But right now, the
ocean and buoyancy of argo engine doesn't
work with a skeletal mesh. That's why we have
a static mesh of the exact so if you want
to have another ship, you need the aesthetic
mesh of it as well, exactly at the same size. You can use one of its LODs. If you have a three
D artist designer or UNO blender or three D Max or Maya, you can do it yourself. Just one of the low
poly LOD of it, create a estatic mesh of it, and imported in AL engine.
That's what you want to do. So first thing first,
inside this BP ship, what you want to do we
want to click on AD and add a estaticms
because we know that ARL engine buoyancy and ocean will work with
estatic mesh correctly. So add estatic mesh. And because we select the estatic machine here and
we did create it over here, that's why it did put it there. You can see this is
our ship, right? And it's called untitled. Let's just change
that to ship for estatic mesh and drag and drop it and put it
as default sin root. Next, with that, what I
want to do I want to add a skeletal mesh now as
a child of it, right? I want to call it ship. Right? And for the
skeletal mesh of it, I want to choose SK west ship, right? Just put it there. Now, you can see both
of them in in here, but we want to
click on our ShipSM and change the visibility of it. So let's just go down until
we see the visibility. We don't want it to
make it visible, right? That's it. Now, we have
a ship that we can use. With that done, we need
to add a spring arm. So with it, we have
a camera as well, and click on the spring arm
after that and add a camera. Add the camera in here
as child or spring arm. Now, with or spring arm, I want to change the length
of it to 15,000, right? So it is way back.
You can see it. The camera is way back
in here. So that's good. If you want to change the target arm length to something bigger or
smaller, you can do that. Next, let's just add
some offset to the Z. So we bring it up a little bit. Example, 180, and next
thing that we want to do, we want to enable use
pawn control rotation. So the rotation or spring arm change with the
rotation of our controller. No, next thing
that I want to do. I want to click on or ship aSM and add the
arrow there as well. With this arrow, I want to
check the forward vector. So click on it. And because you can see it is
too small over here, we can't see it good. So I need to make it bigger. Change the arrow size
to something big, 130. No, you can see
the forward vector or what is the direction
in forward, right? Forward ctor. Now with that now, let's just he compile save. I want to go to Content drawer and I want to go to Ship folder. After that, in Blueprint folder, I want to right click, create
a new Blueprint class. This time, I want to create
it from game mode base. I want to call it GM BP
for game mode blueprint. And we want to call it ship. That's it, don't click
on it to open it. And in here, the only
thing that you want to change is default punk class. So click in here and
change it to BP sheep. That's all we need to do
inside this blueprint. You can just close
it. Now, we can go to our level and go to Wordsetting. If you don't have
this word setting, you can go to Window and
open up the word setting. In here, we want to change
the game mode overt from non to GMBP Shep. That's it. No, I here, we have player start? Let's just find it
and put it on water. Right now, it is not on water. Let's just at F to see where
it is. You can see it. It is over here. Now with that done,
if you run over game, you can see, we have the
ship, we can't move. I won't fall down at all. Let's see how we can fix that. For fixing that, we
need to go to BP Ship, click on ShipsM in here, we want to enable
simulate physics. We want to change
the mass to 100, for example, so it will be
easier to manage it, right? So we don't need to put a lot of force to
it, so it will move. So with 100, it will be easier. Next, let's just go
down and in here, the collision presets, we
want it to be physics actor. If it's not physics actor, just click in here and
change it to physics actor. And that's it, Let's
just had compile, save, and go to
our level and run. No, you can see it will
fall off into the water, and you can see
it's not floating at all. This is a problem. Now, with that, you
can see the depth of our ocean is not
too much in here. Let's just put it over here
and no, let's just run. You can see it is
going inside the water and it's hitting the ground
beneath the water, right? We don't want that to happen, so we need to make it float. How we can do that,
there is a tools in our engine that c buoyancy, and we want to use that next
4. 03 Ship pontoons: No, we have a ship, but it is sinking. How we can make it
float. Let's see. For making it float, there is a tools in Area engine
that is called buoyancy. So click on ad and search
for buoyancy, right? This is the one. Click
on it too, add it there, and know with that, you can see there is a buoyancy option. So we need to set
up buoyancy data. If you expand this, you can
see we have lots of things to set over here and make
it customized, right? So first thing first in here, we should add some pontoons. With these pontoons, we can make a boat float to make
our ship float. And how we can do that, if
we open up the estatic mesh, you can see inside
this estatic mesh, I did create some sockets, and you can see the
first socket that I create is at the middle
at bottom of our ship. There are other sockets as
well at front, two at front, atside of our sheep, and there is two at back
aside of or ship as well. If you want to add more, you can do it. For example. Let me create the sixth one. If you click in
here, it will add another one, and I
can position it. For example, I want one of
them to be here, right? At back of over a static mesh, and we can add more
at front as well. For example, add one in here. So click on at and
add it at front, right, like this.
And we can name it. For example, this one, head
F two, so you can rename it. Put six there, and this one, I can put seven there, right? So no these sockets positions
we can use pontoons, right? So for example, the
socket number one, the position, the relative
location of it is 00 -500. The socket number two is
this relative location. The number three has
this relative location, and we want to use this sockets position
to place our pontoons. So no, for creating pontoons. Let's just go to BP
ship, and in here, click on buoyancy and
add some pontoon. I need just five of them, but if you want to add
more, you can do it. So click in here to add
five no, for the first one, you can see, we can
put a socket there, but for some reason,
it doesn't work. It has a box. So I
won't use socket, but I will use
relative location. So, for example,
the socket number one has the relative
location of zero, zero -500. So let's
just put it there. 00 -500, right? No, the radius you
can change it, how much you want it to be big, but 100 is more than enough. Let's just go to the
next one. Index one. Again, I don't want
to use socket. I want to just use
the socket location. So let's just go here.
The socket number two. I can right click in here, copy the values over here, and go here and right click in here and paste it over here. You can see, no, I
did put it there. I don't need to change anything. No, I can go to index two. For Index two, I want
to go to socket three, right click in here,
copy the positions, and let's just
paste it over here. Right click paste, and it
will put the values there. No, we need two more in here
for socket number four. I want to right click copy the position and paste
it for this one, right? Right, click Paste. That's it. No, there is just one more Well, just click in here
on number five, right click Copy and go
to BP ship and in here, paste it for relative
location, right? No, you know that we have
six and seven in here, but I don't want to use them, so I can just delete
them. We don't need it. If you want to add
them, you can add them. You can add more pontoons in here and add their
position as well. But these five is more than enough because if
you have more pontoons, it will be harder for PC and
CPU to process all of this, and we will have
drop in frame rate. So no, let's just he compile, save go to Olevel run over game. No, you can see it is floating. If I hit F eight and
go into the water, you can see it is floating. But you can see this
is hitting the ground. But as you can see,
it is floating. For you to see it better,
what I want to do, I want to stop this and click
on water body ocean and bring it up a little bit like this and know that if
you run over game, if I eject and go
beneath the ship, you can see, it's it's floating. It's not hitting the ground. So over ship is floating and everything looks
good, everything awesome. Now, let's say you
want the back of over ship to be a little bit
down how we can do that. For doing that, we can
go to our BP ship, click on buoyancy and change the Z value
of the ones to -20, for example, for both of these, -20, and we can decrease
this more to -20. It's just for this.
Let's just head compile and run, no. Can see. No, it is completely into the water and
down. You can see. That looks really awesome. If you want to just leave it with these values,
you can do it. But if you want to change the position of these
pontoons, you can do it. You can bring the pontoons up. So this sp goes down
into the water more. You can play with these values until you reach the
result that you want. But right now, you can
see it is into the water, and I think it looks
awesome and it is floating. No, it's time to be able to look at overshp with the
inputs with the most. Let's see how we
can do that in next
5. 04 Input mapping: No first thing that we
want to do we want to be able to look around
with our mouse. For doing that, we need
input mapping context and some input action. So let's just go to ship folder. I want to right click in
here, create a new folder, and I want to call
it inputs, right? Do click on it to open
it, right click in here, go to input and create a
input mapping context. I want to call it IMC ship. Dog click on it to open it. After that, I want to
create input action. So right click in here again, go to input and
create input action, and I want to call it IA L around A for
input action, right? No, don't click on
this input action. I want to change
the value type from digital Bollan to
access to D. So what you want to do
with the X and Y of mouse we want to be
able to look around. So let's just save this.
We can just close it. Go to IMC ship input
mapping Context Shep, click a Mapping to
map or input action. Click in choose I look
around and in here, how we want to look around, we can just click in here, go to moose and put Msx
Y to the axis, right? It will give us X
and Y of our mouse. Now, with that done, we need to implement our IMC
ship inside or BPsp. So go to event graph in
here at the begin play. I want to get the
player controller in here, and with that, I want to get the enhance
input local player subsystem and add over mapping
context to it. Add mapping context, right? We want it to happen just once. It is more than enough. The mapping context
that you want to implement is called IMC ship. Now with that done. If
you go down in here, find some space, right click
Search for IA, L around. There is two of them. One is action value and one
is action event. We need the action event. So click in here to
it there, right? No, the action value, if we drag and
drop and break it, break the vector two D, it will give us X and
Y of our moss, right? And with it, we can change the rotation of our controller. And because on this spring arm, we did tell it to use
paw control rotation, it will use the rotation
of our controller. So in here, the only
thing that we need to do is changing the
control rotation, for example, with X, we want to change the
control a rotation. So we look left and right. Rotation around the Z axis, it is called Ya. So we say add controller. Your input with what
value with the X, right? Just with that, if you head
compile and run, you can see, with the mouse, I can
look left and right, and that does look good, right? Now, the next thing
that we want to do, we want to change the control, pitch rotation or rotation
around the Y axis, so we can look up and down. And for doing that, again, we can say art controller, pitch input with the
Y value of over most. Now with that one, if you head compile save and Runo game, you can see I can
look up and down, but it is inverted. So for making it invert again, so it will be easier
to work with, we can go to IMC ship. In here, we can add a modifier
to over input action. So add the modifier in
here of type of negate. And the only thing that you
want to negate is just the Y. So unselect the X and Z and
just leave the Y there. Just with that, if you had
safe and run over game, no, you can see we can
look up and down easy. We are looking around over ship. Now, it's time to
move over ship, move it forward and backward. Let's see how we
can do that next
6. 05 Moving forward and backward: Now let's see how we can
actually move over ship. How we want to do it because
it is a physics body, we can apply some force to it. Let's see how we can do that. For doing that, first of
all, we need input action. So right click in here, go to input and create
input action. I want to call it I move
forward, backward, right? I'll click on it to open it. The value type, I want it
to be axis one D, a float. That's more than enough.
No, we want to map it. So go to IMC ship
create a new mapping. We want to do it for move
forward and backward. And in here, we want it
to happen with W with W, we go forward and add
another input this time, click in here, head S on your
Tboard, put the S there. Whenever we had S, we want to go backward
and we want to have a minus value. A negative value. So that's why I want to add a modifier of type
of negate like this to pass minus one whenever
we hit S on our keyboard. Now with that done, let's
just go to our BP Ship, find someplace, for
example, in here, search for A, move
forward and backward. And in here, let me bring
this down over here. First thing that
you want to check, we want to check
our buoyancy and check if it is in a water body. So if it is in water, we can move it
forward and backward. So we will check this with the branch to connect the
execution pin to it, right? If we are in the water, this true will happen, and with that, we want to get our ship SM and add force to it. So search for add force. That's it and connect
the true to it, right? No, it needs a force. How we can calculate this force. We want to add this force in forward direction
of our ship. And you remember we add
this arrow in our ship, so we get the forward vector
of overship with this arrow. So we can get this arrow get
the forward vector of it, search for Get forward vector. Next, because this forward
vector is a length of one. I won't move or ship, so that's why we need to
multiply it by some big value. So right clicking here,
change it to float. So we multiply or vector by a big float
value like 320000, for example, we need to test this until we reach the
result that we want. For no, just leave it
as this value, right? A really big value. Now with that done, we need to be able to go
forward and backward, and for doing that, we can use this action value. If we W, it should go forward, and it is giving us one. And if we S on or keyword, this action value
will be minus one. So we can multiply, multiply this by
the action value that whenever we S,
it will give us. Minus one and whenever
we hit W d one, and this is our force. We can just put it
there. Now if you had compile save go to our
level and run over game. Now, if I hit W, you can see it is going forward. And if I it Son or keyboard, you can see it is going
backward. That's good. You can see the
force is too much, so we need to decrease it. Of course, again,
you should play with these values a lot. For example, I want to
divide this value by two. Now, if you go to our
level and run over game, you can see it is
going forward and we can go backward and
it does look good. So no next thing
that we want to do. Whenever we are going forward, we want to rotate these blades that we have
at the back of our ship. So our ship looks much better. Right now, if you go
backward or forward, you can see the blades
are not moving. Let's see how we
can do that. Next.
7. 06 Rotate blades: Know that where ship is moving, we need to rotate the blade so it looks much better, right? So for doing that, we
need animation blueprint. So let's just go
to content drawer, go to Ship folder, go to Blueprint and
in here, right click, go to animation and create
animation blueprint. I want to create it for
a scale West ship head create and I want to
call it ABP ship, right? And don't forget to put this animation blueprint for
ship a skeletal anim class. So click in here and
it will put it there because we select it
over here, right? Or you can just click in here
and choose the ABP ship. That's it. No, these
two is connected. Let's just see what
we can do with that. Double click on the animation
blueprint to open it. And in here, first thing
that you want to do, let me make this a
smaller in here. I want to search for
mesh mesh space RFO, so it will give us
all the information about the bones inside
our skeletal mesh, right? Now, we can do whatever we want with the bones that our sp has. Let's see what bone
we want to rotate. For doing that, I want to go to a skeleton by just
clicking in here. With that, it will open up
the skeleton on our sp. The bones that we want to
rotate is these blades in here. Let's just see which one is it. Click on screw joint. You can see, this
is the first one that you want to
rotate like this and we have left
screoint LF screw joint. Again, we want to rotate
this as well as you can see. These are the ones that
you want to rotate. RT joint. And L F screw joint. This LF means left. This RT means right. Now, how we can do that. For doing that, we
have a node that is called modify bone
or transform bone. And in here, the bone
that we want to rotate, you know that it is we the screw joint and
left the screw joint. So choose one of them. We will copy and paste that
for the other one as well. What we want to do
we don't want to change the translation
or a scale. We want to just
change the rotation. So in here in detail panel, we can tell it to not expose
the translation as pin. You can see it is much cleaner. And for the scale, again, click in here and tell
it not to expose as pin. Now, right click
on this rotation, split a stroke pin, so we can just change one of
these rotations. But for no, which one
do we want to rotate? If we go back to our skeletal
mesh and he told you, you can see the rotation
around the X axis, we want to change, right? The rotation around the X axis, this red one is called role. So that's why we need to
change just the role. By default, it will
ignore the rotation mode, so we need to click in
here and change it to add to existence, and that's it. Now, if we change the role, zoom in here a little bit. We are doing it
for the left one. So if you change the row to, for example, 20
and head compile, you can see it is rotating. But I don't want to
do it like this. I want to right click on this
one, promoted to variable, and I want to call it
blade rotation, right? Blade rotation. Know
with that done, we can test it in an
in preview editor. If you don't have this, you can go to Window and open
up an in preview editor. By default, it should be there. Now with that done,
if you change the value for blade rotation, you can see the blades are
rotating. That's cool. Now, we can copy and paste
this node with Control C, Control V to paste it over
here and connect it like this, right to here and here. In this one, we want to change the right blade or
right screw joint, change it to that and we can use the same variable for the
role of this one as well, head compiler, save, and know
if we go to preview editor, you can see we are rotating both of them with changing
this value, right? But how we can
change this value. We want to do it based
on the action value, based on the inputs
that we have. So let's see how we can
do that next video.
8. 07 Force Factor: No, based on the inputs for
going forward and backward, we need to rotate the blade, but how we can do
it. Let's find out. For doing that, I want
to go to BP ship, and in here, on each frame, I want to check if there
is any input, right? So in the eventi, we
want to check that. So every frame, we are
checking that, right? But I don't want to mess
this event tick up. What I want to do, I want to create a custom event in here. Search for custom event. I want to call it engine. Manager, right? So, based on the engine, the force that we have,
the movement that we have, the input that we have, we want to rotate
the blade, right, and we want to connect this
custom event to the eventi. So in here, just put the
engine manager in here. It's like, whatever
we connect to this custom event in here, engine manager, it's like
connecting it to the eventi. Now in here what we need
to check is to check I move forward and
backward action value this time, action value. We want to check. If
this action value was bigger than zero, it means we are going forward, and we want to check that with
a branch like this, right, connected like this and know
if we are going forward, this I move forward backward will give a value
bigger than zero, one, at most cases, right? This true will
happen, and with it, we want to smoothly
rotate the blade, right? So how we can make it this move, we can do it with a variable. So let's just create a
variable of type of float and I want to call this one force factor,
force factor, right? Just call it force factor. And by default, this force
factor will be zero, and we want to smoothly
change it to one. And how we can do
that, we can do it with F interp two, right? The thing that you want to
change is our force factor. So connected to the current, the target, we
want it to be one, and we need the
Delta time so we can get the word Delta second for that and the interpose bit want to put it on two or
whatever value that you want. And no this node
on each frame will give us a value closer to the target
value that is one, right? So we need to save that inside over force
factor like this. And connect the
execution pin to it. So we are smoothly
change the force factor 0-1 if we are going forward. No, next thing that
I want to check. Again, I want to check
the input action in here, and I want to check. If it is equal to zero, it means we are
not moving at all. So we need to smoothly change the force factor
to back to zero. So if there is no input, this zero will happen. We can check it with the
branch again, right? If there is no input, this true will
happen, and again, we want to change the
force factor smoothly. So we can copy all of this with Control C and Control V
to paste it over here. But this time because
there is no input, we want to change back this force factor
to zero. That's it. Now, if this false will happen, it means the input
I move forward, backward input is a value less than zero because
it's not more than zero, it's not zero, so it
is less than zero. So again, what we want
to do we copy all of these control C
control pay setting here in case of falls. It means we are going backward. We are heading S
on over keyboard. That's why this IA move forward and backward is
giving us a minus value. And with that, we need to change this force factor from
whatever value it has to a negative value minus
one, for example, right? That's all we need to do. Now, let's just
say set if we had compile save what I want to do, I want to go to Aventq right in here and
use a printes ring. So let's just use a
print ring in here and show the force factor
just connected to here, and it will automatically
convert it to a string, so it will show it to us, right? Now, if you run over game,
let's just look at it. If you run over game, right now, it's put in zero. But if we had told you, you can see it is smoothly going to one or
closer to one, right? Now, you can see or ship hitting the ground and it
will go backward, right? But let me see how
we can fix that. We can just put
the player start. Let me at F to see where it is. It is inside the water. We can bring it a
little bit in middle, so it won't hit
that easily, right? Now, if you run or game, you can see when we are in here, if you hit W, it will smoothly go to one
and you can see it. And if we go backward, it will smoothly
go to minus one. You can see that
looks really awesome. But we are just
changing a variable. With that variable right now, we can't rotate the blades. Now, let's see how we can use this variable to
rotate the blade.
9. 08 Blade rotation: No for using that force
factor to rotate our blade. For doing that, I want to
go to Animation Blueprint. And in here first,
we need to get that force factor in
event graph, right? In here, first of
all, I want to create a begin play event
Blueprint begin play. And with this node that is
called Try Get Pawn Owner, we can get over BP Ship, right? We can cast it. Two BP ship, right? So if this cast succeeded, it means we can right click on this BP ship and promote
it to variable so we can get whatever variable that we want from
inside of this BP ship. For example, if I go down, let me make this smaller. In here, we get our BP ship. First of all, we
check if it is valid. So search for is valid, right? And if it is valid, we can get the force
factor off of it. So search for force
factor and get it. Now with that done, we can change the blade
rotation value variable that we are using for rotating over blade with
this force factor. But how we can change this
blade rotation with it. First, we want to
check if it is valid, change the blade
rotation, right? Know how we can use
this force factor. We can multiply this
by some value, right? But with what value? We know that this
force factor is a value between
minus one and one. That's why we multiply it by
some value. But what value? We want to get the
blade rotation. Get the absolute of
it, absolute, right. And each frame, we
want to add to it, right, at like 15 unit. And if we just do
that and connect these to blade rotation,
what will happen? If we run over game, you can see it is
always rotating, right? It is always rotating. Doesn't matter if we
are moving or not. It will be always rotating and that doesn't
look good, right? That's why we need to
use this force factor. This we have, we
can multiply it by force factor and connect the
result to blade rotation. So if we are not moving
and there is no input, this force factor will be zero, zero multiplied by
whatever value, it will give us zero, and there will be no movement. But if we are going forward, this force factor will be one and one multiplied
by whatever value, it will give us whatever
value that it is, and the blade will rotate. But if we S on or keyboard, this force factor will be minus one minus one by whatever value, it will negate that
whatever value, and it will rotate
on the other way. Now, let's just say that.
If you had compile save, and go to a level
and run over game, no, you can see if I go close. If I had to you, you can see it is going
forward. That looks awesome. And if you release
it, you can see it will stay to zero, right? Again, if you go backward, you can see it will
rotate the other way. That's cool, right? We are going forward
and backward, and it does looks good, and it is rotating. One problem that
we have in here, whenever we release
WK just look at it. If we release WK, all of a sudden, it will go
backward a little bit, right? So for fixing that,
first of all, I want to increase this value. So every time the blade
rotation increase more, for example, 50, right? So it rotates much faster. Next thing, go to BP ship, and in here for going to target zero whenever
there is no input, I want to change
the interpose bid to really big value
like 20, right? Now, if we head compile
and run over game, no, if you look at it, you can see the blades is
rotating much faster. And if you release
WK on our keyboard, you can see that does
looks much better, right? That's better. We are
finished with blade rotation.
10. 09 Going left and right logic: No, for actually
going left and right. Let's see how we can do that. For doing that, first of all, let me delete this printer ring. For going left and right, first, we need an input. So let's just go
to content drawer, go to Ship folder, go to input and
right clicking here, go to input and
create input action, and I want to call it
IA Move left, right. Okay? And I'll click
on it to open it. The value type, we want
it to be Axis one D, make sure you save. And after that, we need to
map it inside IMC sheep. In here, add a new mapping. We want to map DIA
move left and right. We want to move left and right with D and A
onward keyboard. So click in here, head
D on your keyboard. No, the D will pass one
through D input action. No, we need another one for A. So click in here, head A, and because we want
to pass minus one, whenever we head A, we need
to negate it with a modifier. So click in here, add
the negating here, and it will negate it for us. Now with that done, if
you go to our BP ship, let's just find some
space, for example, down here, right click in here, search for IA moves
right and left. We want the event,
so choose the one that is child up enhance
action event, right. First in here, we need to check if we are in water or not. So we get this buoyancy. If you are not in the water, we shouldn't be able to
go left and right, right? So in here, we check
in water body, right? We check that with a
branch. Like this. After that, we want to check. If the speed is a little bit, we have some speed, but
how we can get the speed. Forgetting the speed, I want to go to event tick
and show it to you. So in here, I want to use a printer string,
print a string. And in here, I want it to be persistence because
we need this speed. I want to change the
key to a speed, right? No, the string that
I want to show, I want to create it
with a format text. So in here, I can say a speed. Is equal to open and
closed curly braces. And inside this, I want to
say S for a speed, right? No, we can connect
these two in a string, but we need to replace
these curly braces with the variable that we
connect to this Spin, right? So how we can get the speed. For getting the speed,
we say get velocity. Okay. And with this velocity, we can get the length of it, vector length, X and Y, and we can show it with
connecting it to the S, right? Now, if we head compile
save and Runo game, you can see the speed
right now is zero. If we go forward, the speed, you can see it will increase, and it is based on
centimeter, right? So we need to first change it based on meter, for
example, right? So for doing that, we
can divide this by 100, so it will give us meter, right, and connect
it like this again. Now, if you run over game, you can see if we hit, the speed will increase, and if we release W, the speed will decrease. No, one problem that
I see in here is that we are releasing
WK but it's moving. So we need to find a way to
make it stop much faster. You can see right now
we have a speed, right? So if you don't want to
decrease the speed really fast, you can do that, but it will cause a lot of
problem in future. So that's why I want to
click on where Ship SM. And in here, I want
to go to linear damping and angular
damping and increase them. So for linear damping, I want to put it on 0.5
and angular damping, I want to put it on 0.1. Know with that, if you run over game and have some speed,
let's just go forward. When we release WK, you can see the speed
stop much faster. A speed decrease much faster, and we can go forward. And if we release WUKi, you can see the speed will decrease much faster.
And we want that. It's more natural
to do it this way. So now we have a speed. What I want to do
with all of this, I want to grab all
of it and right click on it and collapse
it to function. And I want to call this
function get speed. And this function, I
want it to be pure. So we can just click on it and tell it to be
pure like this. So with it, it's
exactly like before, because we are not changing anything inside this function, we are just getting something. So that's why we
can make it pure. It will be exactly like before. So if we run over game,
you can see, again, the speed is showing
it to us, right, and we can stop much
faster. That's good. Now, let's see how
we can use this get a speed to go left and right. So in here, if you
go down in here, first, we want to check if
you are in water, right? And if the speed, so we can get the speed again
in here, get the speed. And if the speed was
bigger than, for example, five, if it was
bigger than five, you can go left and right. But how we can do it, this condition is just one. We can't connect both
of these to here. There is a node that is
called boolean, right? With this node, if we are on water and the speed
was bigger than five, this will be true, right? This Boolean will give us true. But if one of these was false, this and Boolean
will give us false. So that's why we are
using this node. So again, let me explain
it one more time. If we are in water and the
speed was bigger than five, this true will happen. But if one of these was false, either we are not in water or the speed is less than five, this false will happen, and this is what
these and boolean do. No, if this true happen, it means we can go
left and right. Okay? But we want to check if
we should go left or right. So we need another
branch in here. And this time, I want to
check this action value. I want to check
this action value, the sine of it, so
search for sine. If sine of this action
value was bigger than zero, it means we are going right. But if it is less than zero, it means a negative value. We are heating A
on our keyboard. So you can go left, right? Just with that, let's just use a print string for
no print sring. And I want to say on this one, go right and I want to change the color of it to
green like this. I want to add the key to here. It doesn't matter what you put
in there, it will be okay. Just copy this printer string and paste it in here
for going left. If false happened, it means the action value
is negative value, so this false will happen, and in here, we want to
say we are going left, the color of this one I want
it to be red, for example. Now, if you hit compile
save and go to a level and run if we hit D or A, nothing will happen, right? But if we hit W and
hit D on our keyboard, no, you can see
it says go right. And if we hit W and the
speed is more than five, and if we hit A on our keyboard, it will say go left. So you can see going
left and right is working fine with our ship. But no, we need to actually
move it left and right. Let's see how we
can do that next
11. 10 Use force local to go right: No, we need to be able
to go left and right, and how we can do it,
we want to do it with force because it
looks more natural. So for doing that, let's
just go to BP ship. And in here, in of these two printesing
what we want to do, we want to add force
to this ship SM right? The static mesh or ship. So add force, this time, we want to add the force at
location local so we can change the ya of oversp going left and
right with a force. So it is easier with at
force at location, local. So just put it there. In case of true, it means
we are going right, okay? And this node needs a
location and a force. For the location because this is at force at
location, local, this location and force need to be in local location as well. So let's see how we can do that. Know that we want to
add this force at the location in
front of our ship. Why? Because if we just add the force at the
middle of this ship, it will go this way. But if we add the force
at front, for example, at socket five, it will
rotate this way, right? So that's why for going right, we want to get the
local location of this socket five to add force to it to this way,
so it will go right. Okay? So let's see
how we can do that. For doing that, we need
to first get our ship SM and get the socket location,
get socket location. And the socket name is
five for going right. We use socket five. But the problem with
this socket location, it will give us the word
location of our socket. But we know that this location
needs a local location. So forgetting that
for converting this word location
to a local location, there is a node that is called inverse
transform location. So search for
transform location. This inverse transform
location will transform or convert a word location
to a local location. So use this inverse
transform location. The location that we want to convert is this socket location, and this node for it to work, it need the ships word
location as well. So we can get the
word transform right, get for word transform
of over ship SM, right? Now this inverse transform
location will convert the socket word location
to socket, local location. Now we have done it for the
location, and it is good. But the force how much
force we want to add, and what direction we
want to add force. Again, if we go to here, we want to add force at this direction to the
right vector of it, right? So for doing that, again, I need to get this ship SM, so let's get it like this. First, we need to
get the socket. Rotation. Get the
socket rotation five. Again, this rotation is
rotation in word space. That's why we need to convert
it to local rotation. Again, there is a node that
is called transform rotation, and it's called inverse
transform rotation. That will convert the
word space rotation to local space rotation. So use this inverse
transform rotation and connect these
to rotation, right? And for it to work
for it to give us the local space rotation
of over socket five, we need to provide it with
the ship SM transform, Word transform of right. Again in here, we say
get word transform, get word transform and
connect it to here. Now, this will give us the local rotation
of our socket five, but we need the right vector. Search for get right
vector off of this, and this right
vector will give us the direction of where we
should apply some force, so over ship, go to
the right, right? But this get right vector is
giving us a length of one. So that's why we need to
multiply this by a big value. For example, 8,000, right, click on this one, change it to float and put 8,000 there. 8,000 is a lot, but let's just test with that and connect
these to the force. With this get right vector, we tell it to which direction you should go, you
should add force. And with this
multiplier by 8,000, we say how much force
you should apply to it. Now, if we go here to our
level and run our game, can go forward and
after that, go right. You can see it is going right. That's good. Let's
just change the player start to face somewhere else
with selecting it in here, head F, we will go there. I want to put it
on this direction. You can see this
forward vector in here. Let's just run and go forward, and now you can see, I
can rotate over ship. You can see it's rotating. And I think 8,000 is too much. If I release D, you can see it is again rotating
a lot, right? Because 8,000 is a lot and the rotation damping
is not that much. So next thing that
we want to do, maybe we should change
this to 4,000, right, and click on or
Ship SM and change the angular damping
to 0.5 as well, so it won't rotate that much. Now, if you go to our
level and run over game, let's see what will happen. If we go forward,
we can go right because the force that
we apply is 4,000, it won't rotate that much. But if we release
D on our keyboard, it won't rotate anymore.
You can see it. Again, we can bring it back
to 8,000 again and test it, so you will see it better. Now, if you run our game, you can see we are
rotating good. But because we have
angular damping, more angular damping, it
won't rotate that much. And if you release
Don or keyboard, it should not rotate that much. And you can see the
rotation is gone. No. That looks awesome.
That looks beautiful. No, we want to go left. You try to do that yourself. We will do it in next video.
12. 11 Go lef right smoother: No for going left. Actually, it is easy. The only difference is
that we want to add force to socket for this time to this direction,
to left direction. Let's see how we can do that. For doing that, let's
just organize a little bit because it is
a mess right now in here. And with that, let me
select everything. Hold control, you can
select everything like this and bring all
of this up here, for example, again,
hold control. We want to bring all of this down so we have
more space, right? And know with that we can
select all of these Control C, Control V to paste it
over here and connect the false to these that
we paste in here, right? The only difference is
that we need to change this socket name 5-4 for
both of these, right? And the other problem that it has we are getting
the right vector. We don't have a left vector. But what we can do with
this right vector, we can negate vector. So just search for negate vector and do this, right? That's it. That's all we need to
do. Let's just check if going left is
working fine or not. Going forward, after
speed is five, we can go left and you can see we are going left correctly. Maybe we should increase
the force a little bit, but I think that is good enough. We are going right and we
are going left correctly. For you to test it better, we can increase this value by multiplying it by two
for both of them. This one as well, multiply
them by two, right? And now if you run, it will rotate much faster. You can see it is
rotating much faster. That's good. And we
can go lift, as well. So let's see what will happen. If we go lift, you can see
it is rotating much faster. But what I want to do next, I want to be able to rotate or ship faster if
the speed is more. But if the speed is less, we don't want to
rotate it much faster. We want to rotate it slower, and how we can do that, we can decide this force value that we have in here
based on the speed. And how we can do that, we
can get our speed in here and use map range clamp, right? And we can say, if
the speed was 0-20, for example, change
the force from, for example, 5,000 to 60,000, right, like this and connect
it instead of this, right? No, if we are moving forward, slower, we will turn right or
left slower as well, right? We can just use copy and pasting from this one to
this one as well. Just control, see control, paste it over here as well. You won't see that much effect, but it will look more natural. If we go forward, the speed is less and we are not
rotating that much. But when the speed is
getting higher and higher, we will rotate more. And if I release W, you can see the rate of rotating will
decrease based on the speed. You can see if the speed
is less than five, we won't rotate at all, and it will stop rotating. You can see it didn't
stop rotating. But if the speed
get more than five, we can go left and
right much faster. It will make rotating left
and right much more smoother. You can see that looks really
awesome and beautiful.
13. 12 Rotate ship gun: No, we are able to go
left, right, forward, backward and all of that, but it's time to be able
to shoot at something. There is a gun in front of our ship that
we want to use it. So let's just go
to a skeleton in here and zoom a
little bit in here. You can see this is over gun. And what we want
to do we want to use it to shoot at
the stuff, right? So first and first, let's see what bones
we need to change, we need to modify. For doing that, we have front gun joint. Let's
just check that. This is for going up and
down, so that's good. Now we have front
gun, edge joint. And with that, we can look
left and right, right? So with these bones, we need to aim at stuff, right? So first, let's see how we
can modify these bones, and after that, we will use
it inside or blueprint. So let's just go to animation
Blueprint for over ship, go to anim graph. You remember we did
change the rotation of some stuff in here
for the blade, right? Right now, we want to change
the rotation for our gun. As you can see in here, we want to change the ya
up front gun He joint, and we want to change the pitch of front
gun joint, right? So we know around which direction we want
to rotate the stuff. First, in here, let me
zoom in here to the gun so you can see it better like
this. Make it a smaller. I think you can see
it good in here. In here, let's just use
one of these nodes, Control C Control V to
paste it over here. We don't need to start
from scratch, right? Connect the execution
or pose into it and know first thing
that we want to do in here, we want to change
the bone to modify. First, we want to be able
to look up and down. So we should use front
gun, we joint, right? As we sit, we need to
change the front gun, joint, the pitch of it. So for example, if I put 45
in there and head compile, you can see, no, it's
45 up, and that's it. We can create a
variable for this one, promote to a variable, and I want to call it gun pitch. That with it, we are
changing the gun pitch. For testing that, let's
just head compile. Change the default value to zero in here and head compile. No, I can go to an in
preview editor in gun pitch, I can change the pitch of our gun and you
can see it's working. But one problem that it has, you can see it can go backward and we don't want
that to happen. Let's see what is the
limitation of this gun. If we go here, you can see it can go this way this
much like zero, right? Let's just put zero. If you look at it, if it go less than zero, it will shoot over ship. So we don't want that. So the gun pitch minimum
value should be zero. But the maximum value, let's just see if you go up, we don't want it to
go more than this. So 40 I think is
more than enough. But how we can use this
value that we found in here, we can use clamp on it, so clamped it to
a certain value. Only use clamp float, and I want it to be 0-40, right so it doesn't matter how much we are decreasing or
increasing this value. I won't get past 40, right, and it won't
get less than zero. You can see it will stay there. So you can see, we have some
limitation on the gun pitch. It shouldn't reach the
back of it, right? No, we done it for this one. What I want to do, I want
to do it for the gun ya. For doing that, again, we can just copy and paste
this one in here like this, connect the
execution, pin to it. And in here, the
only thing that you want to change is the bone, front gun, edge joint, right? And I want to just change the ya it as you
can see in here, front gun edge joint. We want to change the ya
rotation around the Z axis. So if you change these
245 and head compile, you can see it is working fine. If I put -45 and head compile, you can see it is working fine. So we can right click on it, promote it to a variable, and I want to call this one
gone ya, right? That's it. Let's just test that out. First of all, I want
to change the gun ya value from -45
to zero by default. So by default, it is -45. And after that in an
in preview editor, I can change that. You can see, we can rotate it. So now, we have two
variables that with those, we can aim at the stuff. Now, let's see how we can
actually aim at the stuff.
14. 13 Gun camera: Now that we are able
to rotate our gun, we need to have some camera. So with it, we can see where our gun is
looking at, right? So for doing that, let's
just go to BP ship. And in here, I want to click
on Ship skeletal mesh. You can see it over
here. I want to click on Ag and add a spring
arm to it, right? Add a spring arm, and that's it. I want to cod this
one Gun spring arm. So let's just call
it Gun springar. And after that, with
this spring arm, I want to click on AD and
add a camera to it, right? And I want to call this
one Gun camera, right? No, let's just go to Viewport. You can see by default, it is on 00 location for
both of them, right? So what I want to do, I want
to click on Gun Spring arm and because it is
child of over sheep, skeletomsh, we can change the parents socket
to the camera. Now you can see,
where is the camera. The spring arm is
a tip of over gun, but the camera is
way back in here. 300 back, right? I want to change the arm length of over spring arm to 1,000. And now you can see, we can add some
offset, for example, 500 and I want to reposition the spring arm itself
by -800, right? Now, you can see it is
at middle of over gun and I think we can see everything in this
orientation, right? You can put the camera or a spring guard
wherever you want. But I did test a lot with it, and I think this way is good. And when we move this
barrel, what will happen, there will be a shake
inside our camera as well that will make our gunfire
looks much better. Next thing that I
want to do, always, I enable use pun
control rotation. No, a spring arm will rotate
with the controller as well. Now with that, if
we head compile, go to word and run our game, you can see, by default, the spring arm that we put
there it's selected, right? We are moving, and we can
move the shep as well. We can look around as well, and the ship is working fine. But we want to be able to switch between these
cameras right now, we are just using the front
camera, the gun camera. We want to be able to
switch between them. Let's see how we
can do that next we
15. 14 Switch between cameras: Know what we want to
do. We want to be able to switch
between the cameras, and how we want to do
it, we want to do it with right most bottom. Let's
see how we can do that. Let's just go to Content
drawer in Input Holder, right click in here, go to
Input and create input action. I want to call it IA AM. That's it. You don't
need to change anything. You can just close it. Go to
IMC ship and map it there. Add the mapping in here. We want to map the IAA and
with it, let's just go down, expand this, click in
here and after that, right click to put the
rightmost button there. Head save, know we
can go to BP Ship, go to event graph, and know we can implement the switching
between the cameras. So right click in here,
search for IAM, right. And in here, whenever we
press right Mose button, this start will happen. And whenever we
release most button, this complete will happen. So whenever we press
rightmost button, we want to enable this
gun camera, right? And we can do it with
set active, right? And whenever we hold
right most bottom, we want to activate
the gun camera, and we want to deactivate the
camera of our ship, right? So in here again set active
and make it false, right? But whenever we release
rightmost button, all of these we
want it to happen, but in inverse, right? So let me connect
these two here. The gun camera, we want
it to be deactivated, but the camera over sheep
we want it to be activated. Now, with that, licious head compiled save, go to our level, run no, you can see if I
hold right most button, it is at gun camera. But if we release
it, you can see, No, it is at ship camera. Again, right most
button, at gun camera. And when we release
it at ship camera. It's working fine, but
one problem that we have is that by default, it is at the gun camera. We don't want that to happen. So what we can do
about that we can take these lines for deactivating the gun camera and activating
the camera of the ship. Control C to copy it and paste it at event begin
play, like this. Now with that, if
you head compile, save and go to map and run, you can see it is by
default at the ship camera. But if you hold the
rightmost button, you can see it did go
to gun camera, right? That looks awesome, and we can release it to go to ship camera.
16. 15 Rotate gun with controller: No, we can rotate the
camera around the gun, and we are switching
the camera as well. But when we rotate
around the gun, the gun it's not moving
with our camera. So you can see, we are looking
left right everywhere, but the gun, as you can see, it's not moving at all. We know how to move it. We did talk about it. We do it with gun yaw and gun pitch. So we need to calculate what the yaw and pitch
of our gun should be. And where we can do that, we can do it in event graph. So let me first explain how we want to
calculate it. You see? Our gun has a rotation and our camera or the controller
has its own rotation. We need to calculate
the difference between the rotation of
these two and add it to the gun so it will face where our camera
is looking at. And how we can do
that, first of all, we need to get over
ship and with it, we want to get control rotation. This is the rotation that our camera is looking at, right? And next, we want to
get the actor rotation. This is the rotation that
we're going already have. So no, we want to get the
difference between them. We can do it with the
Delta rotator, right? And we need to connect
the control rotation to A and actor rotation to the B. No, it will give
us the pitch and yo that our gun
should have, right? Right click on here,
split a stroke pin. It gives us roll pitch and yo, but we need just
the pitch and yo. We can just set the gun pitch like this with the pitch
that we calculate in here. And set the gun ya with the yacht that we
calculate from here. Give it a execution pin and give it this
execution pin from here. Organize a little
bit. No, with Teton. Let's just head compile,
go to our level, run, and let's just
look at our gun. You can see we are
moving over gun and we can look up and look down. And you can see it won't
go less than zero. You can see and everything, I think, looks awesome, and we are looking
left and right, but know that the
camera is rotating. The gun is rotating. We need to find out where
this gun is looking at. We will do it next.
17. 16 Gun line trace: Know what we want to do. We want to find out where our gun is looking at, actually. So for doing that,
I want to go to BP ship and check
where we are aiming. If we are aiming, we should check where our gun
is looking at, right? So for doing that, I want
to go here and with this, I want to see when we
are aiming, right? How we can do it,
we can check if gun camera is activated
or not, right? So with that, we can check
if you are aiming or not. So know what I want to do at
every frame I want to check. First, if we are aiming or not. If you are aiming at every
frame you want to check, where we gun is aiming at, where is looking at, right? So for doing that
because I don't want to again mess up eventiq, I will create a
custom event in here. So search for custom event, and I want to call
it manage aiming. Right, manage aiming. And I want to connect
it to a ventiq. So let me find Aventiq. We don't need this printer ring, so let's just delete that, and I want to put the manage aiming in here or
aiming manager, whatever you want to
call it, it is okay. Now in here, I want to
use a branch first. Okay. And with that, get the gun camera and check if it is active, right? Is active. If it is active, in that case, we want to check if it is hitting something or
not. W is aiming, right? In case of true, we want to
use a line trace by channel. I need a start
point and endpoint. Let's just see where
should be the start point. If you go to our skeletal mesh, you can see there is
a front gun socket at front of our gun, right? So we can check in
forward of that, right? Forward of the socket where it's looking at,
and how we can do it. Let's just go here, make sure
you save everything always. The start point, we
want to get the ship, skeletal mesh and socket. Location. The socket
that you want to get its location is this one
front gun socket, right? Control C to copy it and
paste it over here, right? Now, this will give us
the start location. But for the end location,
what we can do, we can get the socket rotation and get the forward
vector of that, right? So we can say, get
socket rotation. And the socket rotation that you want to
get, we did copy it. So let's just use Control
V paste it over here. We need some space. So let's
just put this over here. You want to get the
forward vector off of it. And because this forward
vector is a length of one, so it's too small. Or the end point is not enough. So that's why we want to
multiply it by really big value. So right clicking
here, change it to float because we
want to multiply X, Y, and Z with the
big value, right? Like 99999999, right,
a really big value. And after that, we want to
add the start location to this forward vector multiplied by a really big value
to give it that offset, the offset of the
start location, right? And this is our location. For you to see it, I
will click in here and tell it to show a
debuke for one frame. Now, let's just
hit compile, save, go to our level and run. Right, no, there
is no debuke line, but if you hit right
most bottom, no, you can see O goon is finding out what it is
looking at. You can see. I can look at the sky and you can see if it's
hitting something or not. That's cool, right? And one thing that I
want to do I want to increase this value in here, so we make sure it always
hits something, right? Again, let's just
go to map and run. Now you can see it is hitting
everything always, right? It doesn't matter where
we are looking at. Now, with that do, with this square at the
end of this red line, we find out that it
did hit something. If you go to a sky, if
there is no square, it means it didn't hit anything. And how we can get we can get it with this
out hit result. So we can just break it and
check this blocking head. If it did hit something or not. First thing that I
want to do in here, I want to right click on this blocking head and
promote it to a variable. I want to call it Is it, right? That's it. And connect
the execution pin to it. We want to see if our gun is hitting something or not
if we shoot it, right? Next, what I want to do? I want to use a branch Okay. And check. If it
did hit something, save the location that
we hit that something. So we can promote
this to a variable, and I can just call
it impact point. It's more than enough. In case of true, we want to save the impact point
inside a variable. But if it didn't hit
anything, again, we want to save
this impact point, Control C control V to paste it. But with what value? With the trace end, that end location, put it there. Now with that done, we know if we are hitting
something or not, and we are saving
where we are heading. If we are hitting something and it is successful,
we will save that. But if you are not
hitting anything, we will save the trace
where it ended, right? This end location
that we have in here, it will give it to
us in here as well, and we can save it, right? That's it. We want to use all of this information to be
able to shoot at some
18. 17 Crosshair: No, we are finding out where we gun is looking
at or hitting at, but we don't have any cross
hair for showing that. Right now, we are showing it with a D draw debot type, right? We show it with
debo of Are engine. We need some crosshair. So for doing that,
let's just go to Content drawer, go
to Ship folder, right click in here,
create a new folder, and I want to call
it Widgets, okay? Widget. In here, right click, go to user interface
down here and create a Widget blueprint
of type of user widget. I want to call it
DBP, crosshair. I'll click on it to open it. In here, the only
thing that we want to do we want to add an image. And with this image, I want to change the
image to cross hair. MD, this one, right?
You can see it. Don't worry about
the stretchiness of it. We will fix that. The tint color of it, I want to click on
it and change it to a black one and change the a little bit so we can see pass through
it, right, like this. You put whatever value that you want if you want to
change the color or not. I will put 0.5 for the Alpha. That's it. This is
our cross hair image. Now, we can go to our BP ship. I want to click on or ship SM, click on add and add
a widget, right? Just add a widget
and I want to call it cross hair, right? So first thing with
this cross hair widget, we want to change the space from word to a screen so we can always see it and it won't
go behind the stuff, right? The widget class that
we want to create is called WBP crosshair, the one that we create together. And the size of it,
I want it to be 100 by 100. That's
all we need to do. Now, let's just compile,
go to our level. Now, you can see the cross
hair there. You can see it. We have the crosshair, but the positioning of
it is not good. Actually, you can see we can see it when we are
looking this way, right? So how we can change the
position of our crosshair. Actually, it is easy. We can get our crosshair
over here, right, get our crosser and set the
word location on it, right? Set the word location on it with the location that we have
the impact point, right? We can get the impact point
from here and put it there. In both of these cases, this set word location for our crosser, we
want it to happen. So let's just at compile, save and know if
you run over game, you can see wherever or gone is aiming at the
cross hair will be there. You can see it is
at the middle end, it does look good, right? But one problem that we have, if you go here and we
are looking at overship, you can see the problem. We shouldn't be able to
aim at overship, right? So let's see how we can fix
that problem in next video.
19. 18 Crosshiar visibility: Know what we want
to do. We want to avoid being able to
shoot at a ship. So let's see how we can do that. For doing that in here, after we check if we are
hitting something or not, we need some space in here. So let me bring all of
this to right like this. And in here, we want to check if this head actor
that we have in here, if it is equal to
self create self. If it is equal to self, we shouldn't be able
to hit anything. So what we can do, we can check with the branch
in here, and with it, if it was self, the true will happen, and we don't want to
set this impact point. So hold control, dragon
drop put it to falls. If it wasn't self, you can save the impact point and you can shoot there, right? And if it was self,
what we want to do, we want to set our crosshair in here and set the
visibility on it. So set visibility
to falso, to fals. But in other cases in here, we want to set the visibility
of crosshair to two. Now with that, the crosshair, which disappear whenever we are aiming toward
overship, right? But let's just check it if
it's work or not, right? In here, you can see if we are looking away,
everything good. But if we are looking
at overship, again, the crossir is not gone, and we can shoot, right?
That is a problem. Why this is happening it's because if we click on our ship skeletal mesh and go to collision category and
go to collision presets, it says no collision. So line trace will ignore it. We need to change
this to vehicle, and we need to
generate overlap and the head event as well
for future uses, right? And after that, we need
to go to line trace by channel and tell it
not to ignore yourself. Now with that done, let's just head compile save, go to our level
and run over game. You can see everything
is working like before. But if you are
facing toward ship, you can see the cross
hair will be gone. That looks awesome, right? No, everything looks good, and we can shoot at our ship. So next thing that I want to do, I want to tell it to not
show in the wg, right? Just put it non because we have a crosshair. We can use it. You can see. No, you
can see whenever we want to shoot our sheep. You can see the cross
hair will be gone. That looks awesome.
That's beautiful. That's what we want it.
20. 19 gun fire conditions: No, based on the
data that we have, we want to decide if we should
be able to fire or not, what we want to check. Whenever we hit leftmost button, we want to see if we should
shoot or gun or not, if we should fire or not. So for doing that, I want
to go to content drawer, go to inputs, and in here, right click, go to input, create input action,
and I want to call it IA fire, right? You don't need to change
anything inside it. You can just map it in IMC ship. So in here, go up,
create a new mapping. I want to hold shift click in here to claps everything,
and after that, release shift click
in here and it will expand all of these without
expanding the childrens. Now, in here, we can
map the IFFre, right? The IFFre we want it to happen whenever we hit Leftmost
button. That's it. Click in here, hit leftmost button and it will put it there. Just with that, if you go
to our BP ship in here, I want to be able to fire. So right click, search for
IAFre right, the avent of it. Whenever we press
the leftmost button, this start will happen. And in that case, we want to check some stuff
with a branch, right? Let's see what we want to check. We want to check if the
cross hair was visible. So we get the cross hair
check if it is visible. It means it's not aiming
at our ship, right? So in that case, we
want to say fire. So let's just use a print
tring and say Fire, right? And in case of falls, again, use another printer ring, say, not able to shoot, right? This one, I want to change it to red so you will
see it better. Now, if we head compiled
save and run over game, if I hit leftmost
button, it says, Fire, right, because we are facing somewhere wherever
we go, we can fire. But if we go toward our ship
and hit leftmost bottom, it will say not able to
shoot. That's one thing. But the next thing
we want to check. If we are not aiming, we shouldn't be able
to fire, right? No, we are not aiming, right? So let's see what
we can fix that. In here, we can use
a boolean like this to check if the crosser is
visible and we are aiming. In that case, you can fire. So for doing that, we can get the gun camera, as you know, If the gun camera was active, it means we can shoot, right? So we check that as well and know if we
head compile, save, and go to our level
and run you can see, if I hit leftmost button, everything is working fine. If we shoot at the ship, it won't be able to do that, but if we go away and we
are not at the gun camera, and if we hit leftmost button, it won't be able to shoot. Now the next problem
that we have, when the main camera is active, we shouldn't be able
to see that crosser. So let's see how
we can fix that. For fixing that, we can go
up until we see the I aim. Whenever we aim, we want to
make the cross hair visible. So set visibility two. Let me connect these to here. True. And whenever
we are not aiming, we need to set the visibility
of our cross hair to false. So make this pulse. Now, let's see what will happen. If we compile save, and if I run our game again, you can see if hold
rightmost button, we can see the crosshair, but if you release it,
no, you can't see it. Okay? No, you can see it because we hold
rightmost button, you can see the crosshair. And if you release it, you
want to be able to see it. But one problem we have. First time that
we play our game, you can see the
crosshair is in here. So by default, we want to
make it invisible, right? So we can go to our BP Sheep, click on crosshair and go
down until you find the visible down find the visible in there and make it
false by default. Now, if you compile, save and go to our level
and run over game, you can see by default, the
crosshair is not there. If you hold right most button, the crosshair will be there. And if you release it, it
will not be there, right? Everything is working fine. If you are hitting the
ground, everything okay, but if you are hitting the
ship, it won't be okay. And if you are in
the main camera, we won't be able to shoot.
That's working fine. We can just get rid
of the printer rings. We don't need that anymore. We know when we can shoot and when we shouldn't
be able to shoot. So delete that and know we
are ready to shoot or gun.
21. 20 Ship projectile: No for firing or a weapon, we need a projectile. Let's see how we
can create that. For creating that,
I want to go to content go to
blueprints and in here, right click create a blueprint
class of type of actor, and I want to call it BP
ship project tile, right? I'll click on it to
open it, and in here, first thing that
I want to add is a sphere. Okay? That's it. And I want to make this
sphere as a default syn root. Next thing that I want to do, I want to create a material for this sphere so it will look red. So let's just go
to content drawer. I will create it just over here. Right click create a material, and I want to call it red. Do click on it to open it. And in here, we can hold tree and hit leftmost
button to create a constant tree vector
or you can just search for constant
tree vector, this one. With this, we can
change set a color. So for example, let's just
choose red. This color, right? And if you connect
it to base color or sphere will be red. Of
course, it's not red. Let's just change
that. If the blue is zero and green is zero, and red is one, it
means it is red. That's it. No, we want to have some emissive color
or glowiness, right. For that, we can multiply this color with a
really big value like 400 maybe and connect it to emissive
color. That's it. I will glow a lot. If we head save, we can use this material. So let's just go
here, click on sphere and change the material to red. Just search for it.
I didn't find it. Let's just go down until
we find it, and that's it. This is the red.
Now, you can see it. Next thing that I want to do, I want to change the size of this sphere in all directions. So I will click in here
to change the size 2.25 because it's too
big for our gun No. Next, I want to go to
collision section. So let's just go down. And in this collision section, I want to click in here,
change it to custom. I don't want this projectile to block the visibility
and the camera, so let's just make
it ignore them, but block everything in here, and that's all we need to do. Let's just head compile, save. Now, next thing
that we want to do. We want to add the
projectile component. Click on AD search for projectile movement
and add it there. No, with this projectile
movement component, if I go up, you can see, I can put initial Speed
and MaxSpeedF example, I want to put 20,000 for initial Speed and
50,000 for maxspeed. That's it. Let's
just test that to. If we go toward the X
because you know that the X is forward vector,
we can simulate it. No, you can see
it's working fine. Again, let's just look at it. That's really cool. This is our projectile
and it's moving. Now, let's see how we can spawn it whenever
we hit leftmost button. Let's just go to BP ship. And in here, if we
should be able to fire, this tree will happen and we
can spawn actor from class. Which class it's
called projectile. So let's just put ship
projectile there. It needs a transform
spawn transform. So what I want to do for that, if I go here, I want to
spawn it a tip of or gun. So this socket is
really important. HadfT on it to rename it, control C to copy the name. And now we can go here and
get a skeletal mesh of asp, and in here, get
socket transform. And the socket that
you want to get is called front gun V socket, the one that we copy together. Now with that, we
can put it there. If you have compile, save and know if you go to our level, you can see, I can shoot it. You can see, everything
is working fine. But the problem
right now is that when it hits something,
nothing is happening. There is no sound at all. So no, we want to check. Whenever it hits something, do some visual fake,
some sounds as well. Let's see if we can
do that. And next
22. 21 Ship projectile VFX: No, we want to add some visual effects to our projectile whenever
it hits something. So let's just go
to Ship Projectile inside its event graph. We can tell it to create event when you
hit something, right? So click on Projectile movement, go down in here until you see the Projectile
stop. Click on it. Whenever it hits something, this will happen and we will
have some impact results. So let's just break
it. Like this. First thing that when it hits
something we want to do, we want to apply some damage. So if it hits something, it should apply
some damage, right? So let's just do apply radio damage because it
is a artillery, right? So it should explode, and that's why we use
apply radio damage. With that, we can just
put a base damage. For example, let's
just use 10,000. The location that
you want to create this radial damage
is the impact point. So let's just put it there. The damage radius, I want to
put it on thousand, right. And next, the ignore actor, what I want to do, I want to create a self reference in here. So search for Rf, get a reference to self, right, and make an array
with this, make array. That's it, and we can connect
it to ignore actors, right? And know the damage causer, we need to set that as well. So connect the damage
causer as well. No, it will apply damage to whatever surface that it's
hitting. That's cool. For you to see it better, what I want to do, I want to create a draw debug. Sphere, right, for that. The location of this sphere, I want it to be exactly
this impact point that we set for
aplo radial damage. So I can hit double
middle most to create a re root node and connect
this from here to here. No, it's more organized
this way, right? No, the radius I want it to be the same radius that we
have it in here, so 1,000. That's it. Now, the duration, I want it to be, for example,
five second thickness. Let's just put ten in
there so we can see it. Now, for the color, let's just use a red color. So again, it will
be easier to see. Now, if you he compile, say it, go to a level and run
over let's just see. If we shoot something,
you can see. Whenever it hits something, it will show a sphere that
show that in this sphere, it will apply some damage. It's for visualization.
At the end, we will delete that, but you
can see it's working fine. Next thing that I want to do, let's just go to Ship
projectile again. I want to add some explosion
whenever it hits something. So in here, I can say
spun system at location. And the location that
you want to spawn it, again, is this location. We can, again, double middle
most in here to create a reroute node and connect
it like these two location. For the rotation of it, I can go here and get
the impact normal like this and make a rotation
from its eggs, right? And connected to the
rotation of the system, the Niagara system
that we want to spawn. We don't need to change
the scale at all. Everything by itself, it's good. No, we should choose
the Niagara effect. It's called Niagara
dust explosion. One, if you have another explosion for
Niagara, you can use it, head compte, save and
know if you run we game, let's see what will
happen. If we shoot. No, you can see there
is a explosion there. Whenever it hits something, you can see it.
That looks awesome. If we can go close to this, for example, ground, you will
see the explosion better. You can see I'm closer
and I can shoot. Now, you can see the
explosion. Good. We have a explosion that
we can use. That's good. No next thing that you want to do for this ship projectile, we want some sound. So in here, I will drag and
drop search for pa sound. At location again. So we want to spawn a sound whenever it
hits something, right? What sound? Let
me click in here? It's called E grenade
explosion. That's it. For the location, again, double middle most
on this location and we can just dry and drop it, put it over here, so we will
be more organized, right? Head compiled, save No. Let's just go to our
map and test that out. If we shoot know, there should be explosion.
You can see it. But the problem is the
explosion is far away from us, but we can hear it completely. That shouldn't be
happening, right? If it's far away from us, we shouldn't be able
to hear it at all. But if you just shoot
overhear, for example, when it hits something, it's
like it exploding near us. So how we can fix that we
can go to Content drawer. I want to go to Ship folder, right click in here,
create a new folder. And I want to call
this one sound. Inside this, I want to go to audio and create
a sound attenuation. To tell it if you are
far away from us, don't play it for us
in that level, right? I will call it essay
for sound attenuation and I will call it
explosion. That's it. Don't click on it to open it, and you can see in here
we have inner radius. So if you are inside
that inner radius, it means we can hear
the sound completely. I want to change that to 2,500, and the follow of distance, it means if you are
inside this flow of distance based on the distance that we have to the
middle of the sound, we hear it less. If we are not in this
fall of distance, we won't hear it at all. And I want to change the
value of it to 15,000, right? Now with that done, we
can go over BP projectile and expand this pon
sound at location and change the attenuation
setting to SA explosion. That's a head compile, save, go to over map, run over game. Now, if we shoot in here, for example, you can
see, we can't hear it. But if we get closer, to one of these grounds, you will see the effect better. If I shoot know,
we can't hear it, but you should hear, we can't hear it because it's
too away from us. You can see? No,
we can't hear it because it did explode near us. You see? It did explode near us. But if we go away like this, we won't hear it at
all. You can see. But if we hit near
stuff like this, we will hear it a little bit. That looks awesome. But one
problem that we have is that the projectile is not destroying after it's
hitting something. For doing that at the end of this execution path after
we spawn sound at location, we can say destroy,
right in here. Just say destroy whenever
the projectile stop moving. Again, let's just test settled. If we go to over level
and run over game, let's just get close
to one of these areas. And now, if you shoot, you can see it will be deleted
after it hits something. Let's just shoot, can see, we are shooting something, but it's not there
anymore like before. And we can hear the sound
a little bit. You see. And after this red
square is going, you can see that red
sphere won't be there. You can see it will be deleted, and it will aploi
damage as well. That was it for Ship projectile.
23. 22 Fire calculated projectile: No one problem that we have. Let me show it to you. If you run over game, you can see we are aiming at that point
inside our level, right? If we shoot, because our projectile is physics
based projectile, that's why it will go like arc and it won't
reach that position. So that's why we
need to increase the initial speed. Let's see. If we go to Ship projectile, we can just click on projectile
movement and increase this by adding just zero
or multiplying it by five, for example, and multiply the
max speed to five as well. Now, let's just see if we are
hitting something or not. If we run over game and
shoot there, let's see. You can it's happening, but it's going so fast that
it doesn't look that awesome. It doesn't look beautiful. So how we can fix that. I want to bring back
these 22000550000, right? In this way, let's just
check it one more time. You can see it does look better
because we are seeing it, but the problem is it's
not hitting anything. There is a node inside Aerial
engine that can calculate how much speed this
projectile should have to reach that point
that you want to hit, right? So for doing that, first of all, we want to check IO gun
is hitting something, if it's hitting something
with the line trace, we should calculate what
the speed it should have, so it will hit that spot. But if it is in the sky and the line trace
doesn't hit anything, just use whatever
speed, like 20,000. It will be okay, right?
No, for doing that, we have something inside
or manage aiming, right? In here, we save if we
hit anything or not. That's where we want to use it. In here, before
spawning or projectile, what I want to do I want
to check with a branch like this and check if it is
hitting something or not. If it didn't hit anything, just use a normal projectile This projectile that
we create together. But if it hits something, this true will happen. And again, we want
to spawn something. But before doing that, we want to calculate the
speed that that projectile should have so it will reach
that impact point, right? So in here, there is
a node that is called suggest projectile
velocity, right? That's it. That's
what we want to use. It needs a start location
and end location. For the start location, we can just use
this sort location for our line trace that
we had from before. So copy it and paste it here for the start
location, right? But the end location, we can use impact point because we want to hit that
impact point, right? Now, we need to put
a launch speed. For example, let's
just use 20,000, right? And that's it. What it will give us, it will
give us a toss velocity, the velocity or speed or initial
speed that or projectile should have to reach that impact point from the
tip of over gun, right? This will give us that velocity. But the problem with this
projectile that we create, we can't set this
toss velocity there. So we need another projectile that can do this kind of stuff. So let's just go
to Content drawer, go to Blueprint and duplicate this
projectile that we have. And I want to call
it ship projectile with a speed, right? So we can set the speed in it, don't click on it to open it. In here, at its begin play, we want to get this
projectile movement and set the velocity on it, set the velocity or a
speed on it, right? But with what value? The value is that suggested value that we have
inside the BPI ship, right? So in here, how we can get that, we can just create a
variable of type of vector, and we can call this
speed or velocity, whatever you want you
can put in there. The important thing is to make it in sense editable and expose on a span so we can set it
outside this blueprint, right? Next, we can just
connect it like this. After that, in
projectile movement, we don't need the initial speed. We don't need the max speed
because with this velocity, it will works, right? No, with this new
projectile that we create, let's just go to BP
shape after calculating the toss velocity that we projectile should have to
reach the impact point, we can spawn actor from class. But this time, we want to spawn the projectile with
the speed, right? With that, you can see, no, we have a pin in here
that it says speed, and we can connect this
toss velocity to a speed. It needs the span transform, and we can just use this span transform that we
have for the last projectile. It's exactly the same as before. Sit over here, make
some space and connect the span transform to a span
transform, right? That's it. Now, if you hit compile save and go to our level and run, no, you can see if I aim at that part and hit
leftmost bottom, you can see the
speed is changing, so it will hit that spot. Doesn't matter where
we are heading. The speed will be changed, so it will hit that spot. You can see it how accurate
it's doing it, right? That looks really awesome. And we want that to happen
because it's really hard with the ship to hit
something far away, right? But with this method
that we have, we are always shooting at
whatever we are aiming. So that looks awesome. But the next thing
that you want to add whenever we
fire over weapon, there is no visualization. There is no sound to tell us
that you fire your weapon. So in Mexico, you will
24. 23 Gun fire VFX: No next thing that you
want to do we want to add some visual effects
to firing the weapon. So let's see how we can do that. For doing that, I want
to go to BP ship, and in here, wherever
we are firing or gun. In here, we are firing or gun. So what do you want to do
at the end of everything? Let me bring all
of this over here. At the end of everything, we want to have some
visual effects, some sound as well, right? So first thing first in here, I want a spawn system attached. This time, we want
to use attached, so it will attach to the
socket that we want. So whenever we move over gun, it looks more natural. In both of these cases, we want to have a spawn system. In both of these cases, we are spawning a projectile and firing over weapon, right? The system that we want to
use in here, if you go down, it's called NS west
ship front gun. Just choose that there. Now we want to attach
it to something. What we want to attach it, we want to attach it to
the ship a skeletal mesh. So put the ship a skeletal
mesh to attach the component, and know we want to tell it the attach point name,
the socket name. Where do we want to attach it to the socket at tip
of a gun, right? So controversy to copy this and paste it
over here, right? Now with that done, let's
just head compile save, go to a level, run, and know if we shoot. You can see there
is a No graphic whenever we shoot
and you can see if you move over barrel,
just look at it. There is a smoke
getting out of it, and that looks awesome, right? Can see. So this is the first thing that you
want to add to our gun. But we want to add
sound as well. For the sound, we can just say spa sound at location, right? And the sound that
we want to play is called ES cannon fire. Just put it there
for the location. We can get our ship and
get socket location. And the socket location that we want to get is
the tip of over gun that is called front Gun socket Control
C copy from here. We can just paste it over here
and connect it like this. Know with that,
head compile, save, and know if you run over game, let's see what will
happen. If we shoot. Now you can see, we
can hear some song. That looks awesome. That
sounds awesome, right? No, the next visual face
that I want to add to this gun is the
recoil of the gun. So whenever we shoot over gun, this gun should go back and
forward like this, right? Let's see, we can do that. Next
25. 24 Gun recoil: No next thing that
we want to do, we want to have a recoil system. And for doing that, let's
just first go to ABP ship, and here, go to anim graph. This time, we want to change the position of the barrel
of the gun. This one. So first, let's find out what
is the name of this bone. For doing that, click
in here to go to a skeleton and find
the gun itself. Let's just click on front gun, H joint, move it. You can see it's
moving whole body. But if you click on
front gun, V joint, with moving this
backward and forward, we are creating
some recoil effect, right, like this.
That looks beautiful. No, we know the name. Front gun, we joined. Let's just go here and move it. So in here, make some space. And in here, again, we
want to use modified bone, and this time we want to
change the translation. So we don't need this rotation. We can tell it not
expose it as pin. We don't need a scale.
Don't expose it as a pin. We need just translation
or position, right? Click in change it
to add to existence, so we add to the position of it. And the translation space, I want it to be in bone space, so it will be based on
its parent bone, right? Know what translation
we want to change. If we go here, you
can see we grab the X and bring it out
and inside, right? So we need to just change the X. So we can right click in here, split the striking and
right click on translation, promote to variable, and
I want to call it recoil. Value, right, or whatever
you want to call it. Now, if you had compile, you can see it give us a warning and it says, you
must pick a bone. We did forgot to
pick a bone in here. So bone to modify, you know that it is
front gun joint. With that, if you had compile, we can go to preview editor
and change the recoil value. You can see it will go
inside site, inside Osit. And that's what we
want to do, right? Now, let's see how we can
calculate this recoil value. For doing that, I want
to go to BP ship, and whenever we
fire over weapon, you can see whenever we fire
over weapon, at the end, we want to create a timeline for changing the position
of our gun, right? So we have some
recoil animation. So in here, I will
search for timeline, and I want to call this
timeline recoil, right. Whenever we fire over weapon, we want this timeline
to play from start. So hold control, grab this and connect it
to play from Start. And no doubt, click
on this recoil. We want it to happen 4.3 second. Add a track of top
of flow track, and I want to call it recoil. Value, right? And inside it, we want to have some keyframe. So right click add the
keyframe at time zero, we want it to be zero. That's it. No, again, right click add another
keyframe at time 0.1, we want it to be one, right? And again, at another key
frame this time at time 0.3, we wanted to go back to zero. Now, if I click
in here and here, you can see it better. For it to be more smooth, we can grab all of them, right click on one of them, and change it to Auto. So we have some curves. You can change these
curves as well. For example, I can click
on this one and bring it. No, you can see the curves. And if the value is not one, you can just change it
to one over here, right? So just with that, it will give us a value on its outside and it's called
recoil value, right? So we can promote
these to a variable, and recoil value name
is more than enough. And with that, if we
had compile save, we can get it inside the animation blueprint,
event graph, right? Again, at the end
of all of these, we want to get our BP
ship again and get the recoil value from
it, get recoil value. And save this recoil value
that is coming from BP ship, inside the recoil value variable that is inside
animation blueprint, connected like this and know the recoil value
that is in BPship is connected to the
recoil value variable that is inside or
animation blueprint. Now with that done, if
you go to Anim graph, you know that the recoil
value right now is a value 0-1. That's not enough. We want to move this
more than that, and how we can do that, we can multiply
this by some value. For example, if I put 200
and connect it to here, let's see what will happen. You can see it did go where. I can see it. And
all of a sudden, you can see that it's not
there because the recoil value in an in preview editor is
really a negative value. If you put it to zero, you
can see it will be there. And if you put it to one, you can see it's going forward. So that's why we need to change this multiplication two -200. No, let's just compile. No, you can see if
I put one in there, it will go inside, and if I put zero in there in there,
it will go outside. You can see this
value is too much. Let's just change it
from -200 to -100. And now, again,
let's just test 0-1. You can see 0-1.
That looks awesome. It will go to one to this point, and after that, it will
go back to this point. Now, let's just test
that inside over level. If you run over game in here, whenever we should look
at the barrel of the gun. You can see it did
go back and forward. Camera is going with it as well. Why the camera is going
with it because we set the camera to be as a child of this barrel
of the gun, right? So you can see, we have some effects with
our camera as well. But the barrel of
the gun itself, it's going back and forward. You can see we have
a cuffix in here. That looks really awesome, beautiful, and
it's working fine.
26. 25 Gun Fire rate: No we have a problem.
Let me show it to you. If you run over game and let's just hit
leftmost button a lot. That doesn't look good, so we need to limit that
and how we can do that, we can do it with this
recoil system that we have. We can just create a
variable of type of Boolean and I call it can shoot. Okay? And when this
timeline is happening, we want to set the can
shoot to folds like this. But when it's finished playing, it means the recoil is
finished and we can set the can shoot to true. No, with that variable, we need to go at
the beginning of this execution path where we are checking if the gun camera is active and
crosshair is visible, we want to add another pin
and check the can shoot. If all of these states
are true, we can shoot. But if one of them is not true, we won't be able to shoot. And now, we're doing
that, we need to change the default value of
this can shoot true. So the first time it can
shoot, head compile save. No go to your level
and run your game. No PC. We can shoot. But if we try to rapid oh. You can't do that. Every 0.3 second, we can shoot. That's more than enough.
27. 26 Gun camera zoom: Next thing that we
want to do because our sheep want a fire
far away from us, we need to be able to
zoom a little bit. So for doing that, I want
to go to content drawer, go to inputs because we need an input with middlemost,
we want to zoom. Right click in
here, go to input, create input action,
and call it a Zoom. Dot click on it to open
it the value type, you want it to be axis one
d. That's more than enough. You can just close
it. Actually, you can close some of
these up for no, and we don't need
this attic mesh. Just go to IMC and add
new mapping, right? The new input action that you want to map is called IA Zoom. So set it there. After that expanded in here, we want to go to Mos and
choose Mos wheel aces, right? Headsave no we can use
it inside our BPC. Find empty space down here, for example, and search
for IA Zoom, right? First, let's see what value it is giving us with the
print est ring, right? Just look at it. We had compile, go to
our level and run, you can see if I go here
and we middle most Zoom, you can see if I go up
with the middle most, it will give us one,
and if we go backward, it will give us minus one. So that's good. Now,
we want to see how we can change the gun camera Zoom. How we can do it, we can get the gun camera and get
its field of view. That's it, and we
want to add to it. So let's just add this
action value to it, right? And after that, I want to clamp it so it won't zoom a lot. We want to zoom a little bit. For example, 60-120, we don't want to less or
more than that, right? After that, again, we can get our gun camera and set
field of view on it, right? That's it with this value. And it need execution pin
so let's just give it that. Now with that down,
let's just compile, go to our level
and run our game. And no with the middle
most, you can see, I'm zooming and I'm on zooming. Can see that looks
really awesome. We have two problem
with this zoom. Whenever we rotate the
middle mose forward, it will zoom and when we rotate the middle mose
backward, it will zoom. This is the first problem
that we want to fix. Next, it takes too much
time to zoom and zoom. That's another thing
that you want to fix. First problem for
zooming and on zooming, we can just multiply this
by a minus value minus one, for example, and connect
it to here to negate it. Of course, we can just negate it inside over input action, right? But let's just see how we can do it just in blueprint, right? Now, in here, we can zoom and on Zoom with middle
most, right? Easy. But another problem is that it takes too
much time to zoom. So let's see how
we can fix that. For fixing that, instead of
multiply this by minus one, I want to multiply
it by minus five. No, it will zoom much faster. Let's just go to level. And in here, if we zoom, you can see it will
zoom much faster. Zoom and on Zoom, much faster. That looks really awesome. No one problem that
we have. Look at it. If you are zooming
right like this, and we release right
moose button, and again, hold right most button, it will go to that zoom level. We don't want that to happen. So what we can do whenever
we release rightmost button, we need to change the field
of view to 90. Default one. If we go to gun camera, you can see the field of
view by default is 90. So we go here whenever we
release rightmost button, this complete will happen, and at the end in here, we want to get our gun camera and set the field of view on it, field of view, right? To what? 90 back to 90, right? Connected like this.
No, let's just statue. If we run over game,
now you can see, I can zoom and after that, release right Mouse button. And again, hit
right moose button, you can see it will go back to Zoom that we wanted
to have again. We are zooming, shoot
and now you can see, it's working fine,
and it's beautiful. Let's just move a little bit. Shoot. You can see. That looks
really awesome. Beautiful.
28. 27 Anti ship blueprint: No, or ship is good, but we need some enemy. And for doing that, we have a artillery that we want
to use it as anti ship. So let's just first import
the files and after that, create an anti ship artillery. So for doing that, there is
a zip file in description of this video that is called
anti ship. Just download it. Put a tunnel this
after that, open it. And in here, we can
just drag and drop this antihe folder to the desktop and it
will be extracted. Now, we want to import
it in our real engine. Click on Content drawer, click on content folder, right, click on it,
show it in Explorer. And drag and drop this
anti ship folder there. It should be exactly like this. The path should be
exactly like this. You shouldn't change the
name or the position or the location of this
anti ship folder in Windows Explorer at all. If you want to do it, you can
just do it in Argo Engine. No, let's just go to
content drawer. Let's see. There is no thing in here, so we need to close ARL
engine and open it again. No ARL engine open again. And you can see in
Anti Ship folder, there is asset folder there. If you go to vehicle east and
you can see it over here. The keletal mesh.
Let me open it. You can see it over here. We can use this
to shoot at ship. No, I want to close this. I want to close
these ones as well. We don't need them anymore. This one has will,
this one has will. We need just the ship, right? No, with that done, I want to go to Anti Ship folder in here, right click create a
new folder in here, and I want to call
it blue print. Do click on it to open
it in here, right, click Create a blueprint
class of type of actor, and I want to call it
BP t sheep, right? Do click on it to open it. And in here, first
thing that I want to add is a skeletal mesh. So add a skeletal mesh. I want to put it as
default scene route, and the skeletal
mesh that I want to choose is called
SK East Rt, right? Just put it there
and you can see it. And this is our artillery
that we want to use. Let's just go to our level. And where I want to put it, let's just put it at
middle in here in here, drag and uro one, dated. So it will face outside, right? Hold out and drag on
one of these axes, and it will create another one, and we can put it over here. Rotate it a little bit
this way, maybe, right? Let's just add
another one in here. For example, these
artilleries are fighting against enemies
on this small island, bring it down a little bit, bring it up, actually. That's it. Now, we have
three artillery that can hit
29. 28 Box trace: No first thing that
you want to do with this anti ship blueprint is that we want to find out the target, and
what is the target? Is our BP ship. How we can get our BP ship. In here at the begin
play, what we want to do? We want to get the player pawn, with this get player pawn, we can cast it to BPP ship. And if it was successful, it means the ship
is inside or level, so we can right click on it, promote it to variable, and we can call it target. Now with that done, we need to check if it
is in our line of sight, if we can shoot at it, right? If it's at front of anti ship, if the target is at front of anti ship
and how we can do it, we can do it line trace, but I want to show
you a new thing. In here, in each frame, I want to check if the ship, if the target is at front of us, so to see if we can shoot
at it or not, right? So for doing that, I want
to do it in every tik. That's why I need to create
a custom event down here, and I want to call it
lineup site manager, right? And I want to connect
it to the eventiq. So search for Lineup
site manager. And know whatever we connect
to this custom event, it's like connecting
it to eventiq. With this, what I
want to do I want to use box trace by channel. It is exactly like
line trace by channel, but the difference is this
box trace has a thickness. We can change the size of it. Now with that done, it needs a start location
and end location. The start location, I want
it to be a tip of this gun. For finding the skeletal
mesh of this gun, we can just click on the
skeletal machine here. And click on open or this
magnifier glass in here, and it will open up the
skeleton mesh for us. I'll click on it to open it. And this is our skeletal mesh. We can open up the
skeleton as well, because it's easier to work with the skeleton in these cases. We want to socket
at tip of or gun. If you go here, you can see the gun joint socket is at
tip of or gun. That's good. We need the name of
it, click on it, Head f two to rename it
Control C to copy it. And now in here,
go to Avent graph. For the start location, we can get the skeletal mesh, and we can get the socket
location off of it. The socket location
that you want to get is gun joint socket. Control past there. This is the or start point, but the end point, we want to see where this gun
joint socket is facing at. So for doing that, again, we can get the socket
rotation this time. The socket rotation
that you want to get is gun joint socket, at tip over gun. And with this rotation, we can get the forward
vector off of it, right? And because this forward
vector is a length of one, we need to multiply
it by a big value. So let's just right click
and change this to float. Like 100,000. That's it. This will determine how
much further or anti ship can hit the ship, right? So this value is important. You need to change it later. Next, we want to add this
start location as an offset to this forward vector multiply by 100,000 to give us
the end location. Node for the half size, I want to change it to ten, ten and 100 for the Z. In this 100, maybe you
need to change it later, but for now, it is
more than enough. Now, for you to see
it, I want to change this draw debc
type to one frame. Now with that, if you
had compile, save, and go to a level, you can see there is
three box traces. That is under the water, right? If we go forward, we won't be able to see it, but if we go, you can see
the line traces correctly. It's going under the water. So what is the problem? Our anti ships are
facing this way. So we need to change
the rotation of our anti ship so it
will face a ship. So let's see how we
can do that next.
30. 29 Anti ship gun pitch: We want to be able to
actually change the rotation of our gun so it will look
up. Let's see what we can do. For doing that, if
you go to a skeleton, let's just find the
gun joint, right? And this gun joint, if you can rotate
it, you can see, this is not the way to do it. After that, we have the
horizontal joint, right? If we rotate this one, you can see, with this, we are rotating it correctly. So what you want to
do, we want to change the horizontal joint so
it will face the ship. And for doing that, we need
the animation blueprint. So let's just go
to content drawer, go to Anti Ship folder,
go to Blueprint. And here, right click, go
to animation and create Animation Blueprint for
a scale East art right? Head creating here and I want
to call it ABP anti ship. And don't forget to set this animation blueprint for
our skeletal mesh over here. Let me make this a
little bit bigger and choose it over here,
ABP anti ship. Now with that done, let's just open up the animation blueprint. And in here, like always, we need mesh, space, ref pose, so we will have all the information
about the bones. We can connect it to output
pose, and that's it. No next thing that
we want to do, we want to modify the bone. Modify bone. And the bone that you want to modify
is called horizontal. So let's just search for it. Horizontal joint. That's it. Now what you want to change, we want to change the rotation. So we don't need
this translation, don't expose it as pin. We don't need this scale, so don't expose this as pin. We want to change
just the rotation, and we want to add
it to existence. And the rotation space, I want to change it to
bony space as well. No, let's just right click on the rotation and
split a stroke pin. Which one of these
you want to change? If you go here, you can
see it is this green one that is called pitch
rotation around the Y axis. So with that, we need to create a variable
to change the pitch. In here, right click
promote variable and what I call it
gun pitch, right? And we can just put
it in here, compile. Now in in preview editor,
let's just test it. You can see, we can
bring it up and down, and that's really good, right? Now how we can calculate
this gun pitch. For calculating it,
I want to go to BP Anti ship and we
have the target. We need to get the rotation from over untiship
to the target, and that will be the rotation that our anti ship
should have, right? So for doing that, again, I need to do
it on each frame. That's why I want to create
another custom event for it, so we don't mess
up this eventique. So let's just go
down in here, right, click Search for
custom event and I want to call it Gun direction. Manager or whatever
you want to call it. I want to connect
it to Even tique. So in here, let's
just search for gun, direction manager, right? It will happen every frame. So no, with that done. First thing first,
we need to get over target and check if it is valid. So search for is valid in here. If it is valid, we need to find the rotation from our Aunt to
the target, right? So for doing that, there
is a node that is called find Look at rotation, right? I need a start point. The start point is get
actor location, right? This get actor location will give us the location
of our anti ship. Next, it needs a target location that we can get it from our target location,
actually, right? We can get actor location of our target and
connected to the target. This is the rotation that our anti ship gun should have so it can hit the ship, right? Now, we want to calculate
the difference between this rotation and the rotation that our anti ship already has. The rotation that our anti ship already has, we can get it. We get actor rotation, right? With this, there
is a node that is called Delta rotator, right? And this Delta rotator will
give us the difference between the rotation that
where Aunt ship should have, so it will face the target and the rotation
that it already has. No, it will give us
roll pitch and yaw. So right click on it, split
the rock pin, you can see it. The only thing that we
need is just the pitch. So right click on it,
promoted to variable. I want to call it
gun pitch, right? And it need the execution pin. So let's just give
it that like this. No, we did calculate
the gun pitch. Let's just see how we can get it inside our Animation blueprint. In Animation Blueprint,
go to Avent graph, and we need a begin play in
here, begin play, right. And because the owner of this animation blueprint
is just an actor, that's why in here, we should get on actor. With this Gon in actor, we can cast it to BP
anti ship, right. And with that, we can get
the gun pitch variable. So for doing that
right clicking here, promoted to variable, and we can just call it BP Anti ship. Now, with that done, we don't need this target pawn owner. We can just get this BP Aunt
ship that we get over here. And first thing first, check
if it is valid, right? And if it is valid, we want to get the
gun pitch off of it. So in here, we did
calculate the gun pitch. Inside or BP anti
ship so we can get it and save it inside the gun pitch that we have
inside or animation blueprint. So let's just connect it
like this to is valid. Now with that one, if
you run Word game, you can see, again,
it's facing down. But for testing that, I want to click on the player
starting here, bring it up. And RunwGame you can
see it is looking up. You can see it is looking up, but it's not facing
over ship at all. How we can fix that
we can just go here in the animation
blueprint in Anim graft. We can add to this gun pitch, add five unit to it like this. At five Unit and after that, connected to the pitch. Now, if we compile and
if we run or game, you can see, it's
facing us better. And if we hit the water, you can see we can go forward, and it can hit us, right? So that's really
good and beautiful. But why this problem
is happening. If you go to BP anti Ship, you remember we get the actor location and we get
the target actor location. What it is giving
us. Let's just see. For the untiship,
the 00 location of this auntieship is down here. That is the first problem. And if you go to
auntieship in here, again, the 00 location
of this one is here. So we need to change the
sort location from here. So that's how you can fix it. But adding just five to
it did fix our problem and it is okay because our ship is really big. Just
leave it with that. No, I want to bring
back this start point. Let's just bring it down
like this and Runo game. No, you can see it
can hit us, right? It is tracing us, and that looks awesome. It can break us, right?
31. 30 Check can shoot: Now that we are aiming at ship. If it is insight, we want to check if we
can shoot at it or not. So for doing that, let's just
go to a vent graph in here. Then we have line trace, right? We want to break this
out had result, right? And in here, we want to check. If it is hitting something's use a branch to check if it
is hitting something. And if it hits something, we want to check
if this head actor is equal to the target, right? So let's just put
the target there. If the line trace
hit the target, in that case, again,
let's just use a branch, and in that case, the true will happen, and I want to create a variable, I don't want to call
it can shoot, right? And we want to set this
can shoot to true, right? But if it's not the target, we want to set this
can shoot to false. Next thing, if it
didn't hit anything, again, we want to set this
can shoot to folds again. Now with this variable, what we want to do, we want to go at the begin play until it. Each five second, try to
shoot at sheep, right? So for doing that, we
can set a timer in here, set timer by event, right? And every five second,
we want to check. If we are able to shoot at
our ship, shoot at it, right? And we want this to be on loop, and we should create
a custom event for the event that every 5
seconds happen, right? I want to call this one fire. And no first thing
first in here, we want to check
if we can shoot if it was true,'s check
it with a branch. Every five second, we check. If we can shoot,
let's just for no, use a printer string. And say can shoot. And if it's false, again, use another printer string
and say cannot shoot, right? And I want to change the
color of this one to red so you can see it better
and collapse it after that. Now we have compile, save
if you run over game, let's see what will happen. Right now, every 5 seconds, it should say can't shoot. You can see there
is three of them, and it will say three
time it can't shoot. But if you go forward, one
of them will say can shoot. You can see can shoot. But two of them is
not saying can shoot. If we go forward,
you can see it says one other one should
say can shoot as well. You can see can shoot. And if we go forward again, the third one will
say can shoot. Let's just look at
it, can see two of them should say can
shoot. You can see it? No, we know when we
can shoot at our ship. Now, let's see how we can actually fire our weapon, right? No, we don't need this
printers ring anymore.
32. 31 Anti Ship projectile: Know that we know when we can shoot or fire or anti ship gun. We need a projectile
to shoot it, right? So let's just go to
contend what I want to do? I want to go to ship folder, go to blueprint and drag and
drop this ship projectile and put it in blueprint folder over Anti ship and
copy it there, right? Click on copy here. And now you can
see it over here. We need to rename it to
Anti ship Projectile. Anti ship projectile. No, let's just don't click
on it to go inside it. You can see in here, we
have apply radio damage. We don't need that. We can
just use apply damage. So let's just delete this
delete this as well. No, connect the execution
pin for no to here. We don't need this draw
debug sphere at all. We can just connect this to here directly,
delete this as well. Now with that done,
first thing that I want to do whenever it hit. The ship, we want to add some force to it
because it is in water. When something hit it, it should move it a little bit. And how we can do that, first, we need to check if you are
hitting the ship or not. So for doing that, we
can get this head actor and cast it to BP ship, right? And it need execution pin. So let's just give it that. Let me bring this
down like this. So it is more organized
this way, right, like this. If it is ship, we want to add
a force at location, right? Just choose one of them. All of them are the same. You can just delete
this connected to it, right at force at
location for over ship, but it needs a target, and it is a primitive
component object reference. We can just connect
the hit component, the component inside over ship that or projectile head, right? No it need a force. Now for the force, we can
get this impact normal. Okay, and multiply
it by a big value. So right clicking here, change
it to float like -250,000, for example, right, and
connect this to the force. And for the location, we can get the impact
point location and connect it to it, right? After that, we can
just connect these to this span system and
all of that, right? Let's just head
compiles save and know that or projectile is half
ready, let's just use it. Go to BP Thip in here
in case of true, we want to spawn actor from a class it is called projectile. It has projectile inside
it, anti shape projectile. It needs to know
where to spawn it, so we can get our skeletal
mesh and get deep sock it transform because we need transform of
the tip of over gun. So let's just go here. It's
called Gun Joint socket, headf two to rename
it Control C to copy the name and click in here, Control V to paste it over here. No, connect it over here. Compile, save. No,
let's just say sat it. If you go forward, one problem
that we can see in here, the initial speed of projectile is that much
that it can't hit us. You can see it will go under the water. That is a problem. We can increase that.
Let's just go to projectile movement and change the initial set
to 50,000, right? That's more than enough.
Let's just it compile, safe and go to our level
and run our game again. Let's just see what
will happen, right? No, you can see when it hit us, it did move the ship. Just look at it one more time. You can see whenever it hit us, it will move over ship. That looks awesome.
That looks beautiful. Let's just go forward to see if it's working this
way, as well. Yeah. Whenever it hit us, there will be a force
added to our ship.
33. 32 Anti ship Projectile force and damage: No next thing that
you want to do. We want to make the tissue projectile a little bit better. So for example, in here, let's just make some space. I want to bring all of these
to the right a little bit. In here, first thing, first, I want to apply damage
first, apply damage. It shouldn't be radial damage. We can just use apply damage. The damage actor
is the head actor. We can just connect it there. It is more optimized
to do it this way. And the base damage let's just use 25 for no and no, let's just test if
you had compile save, go to ship, go to ship
event graph down. Let's just find a space in here, and I want to create a
event, any damage, right? And in here, I want to just show that printer string, right, show the damage to see if
it is damaging us or not. Compile, save, go to or
level, and Runo game. If we go forward,
let's just look at it. It's hating us, and it says 25. So it correctly apply some damage to us. No, our projectile is finished, and it can apply damage as well.
34. 33 Anti ship VFX: Next thing that we want to do, we want to add some
visual effects to our anti ship gun. So
let's just go there. Whenever we fire our anti ship gun, what
do you want to do? We want to add some
visual effects. And this time, how
I want to do it, I want to click in here and
add particle system, right? First one, I want to
do the muzzle flash. The Niagara system that
I want to put there is called NS East RT firing. But you can see the
position of it is not good. So because it is child
or a skeletal mesh, we can just choose a parent
socket. So clicking here. We want to put it
at tip of our gun, so gun joint socket
is more than enough. That's it. That's what
we want it to happen. Again, for CT better, we can change the auto active so you can see it
better. That looks awesome. The next effect that you want
to add let's just add it, add the Nagar effect. And this one, I want to call
it shell ejection, right? And for this one, let's just click
in here and choose NS east RT shell eject, right? Again, the position
of it is not good. So let's just change the
parent socket to this time, I want to choose
gun joint itself. So let's just go down until we find the gun joint or
we can just search for it. Gun joint. You can see this up. We can change its
position until it reached the position that
we want it to be right? I think in here,
it is good, right. That's it. If you
want to check it, I will click on auto active. No, you can see it better, right? That looks awesome. So by default, we want
it to be not activate, so select both of
them and change the autoactive to false
so it won't be happening. Now, in event, grab, whenever we spawn a projectile, we want to get these two, drag and drop both of these, and set active on it, right? Connect the execution pin. For both of them, we want
to do it at same time. So new active to active. No, let's just test that
out, compile, save. No, I want to runway game. Let's just go forward. And in here, I want
to hit F eight, so I can see it there. Let's just go to it.
No, you can see both of the visual effects
is working fine. Look at it. I know
you can see both of the Nagra effect
is working fine. But one problem that
you can see in here, the shell eject is
happening twice. So let's just go to anti ship, and in here, click
on Shell Eject, you can see the rate of fire. We need to change that to, for example, 5 seconds. Now after changing this
rate of fire to five, we need to change the reset of the set active to
through as well. So whenever we are
firing anti ship gun, we are resetting it
and activate it again. Let's just head compile, save, and let's
just test that out. If we run or let's just
go forward a little bit like this and hit the fate to see if it's working
fine now or not. If we go close in here, you can see, both of
them are working fine. The shell eject is happening
at the right time, and the firing is happening
as well. That looks awesome. The next thing that
we want to do, we want to have a recoil effect. So whenever this is firing, it go back a little
bit and forward. Let's see how we
can do that next
35. 34 anti ship recoil: Next thing that you want to do, we want to have a recoil effect. And for doing that, let's just see in our skeleton
what we want to change. If you click on gun joint, we want to change
the position of this gun backward
and forward, right? We want to do this.
So the gun joint is the one that we want, right? Go to ABP, tissue and in here, make some space like this. We need to use this
modified bone again. So search for modified bone. This time, we want to just
change the translation. So we don't need this rotation. We don't need this
scale as well. We need to just change
the translation. So in translation,
change this to add to existence at
translation space. I want to change it
to bone space, right? No, we need to choose
the bone to modify. It is gun joint. So let's
just put the gun joint there. And after that, let's just right click in here,
split the stroking. We need to just change the translation because you can see it over
here, the, right? Now, we can just promote
that to a variable. So right click promote to
a variable and I want to call it thecil value. For testing it let's compile. Now in here, you
can see I can bring it back and forward,
back and forward. That's what we want it to happen so it looks more natural. Now, let's see how we can
calculate this recoil value. For doing that, I want
to go to BP Aunt ship. Whenever we fire the
untie ship, right? At the end of this, we
want to create a timeline. So search for timeline, add the timeline, and I
want to call it recoil. And every time we want to
play from start, right? So hold control, disconnect from this one and
connect it to this one, don't click on it to open it. I want the length to be 0.3, and I want to add a flow track. And I want to call it
recoil value, right? And in here, I want
to add some keyframe. So right click in here, add
the keyframe at time zero, we want it to be zero. And again, right click in here, add another keyframe
at time 0.1, we wanted to go to one and right click again,
add another keyframe. At time 0.3, we want to go
back to zero. That's it. We can just click in here
and here to maximize this. We can select everything,
right click on one of them, and change it to auto. So it has a curve, right? Just with that, if you
go to event graph, we have the recoil value on
output of this timeline. We can just promote it to variable and connect
the update to it. That's it. Let's just
hit compile, save. Now, let's just get that in
our animation blueprint. For doing that, let's
just go to event graph. We have the untie
ship in here so we can get the recoil
value from it, get the recoil value from it, and set the recoil
value that we have in our animation Blueprint with this value that we get
from our BP Anti ship. It need the execution pin, so let's just give it that. No with that, go to
an graph because this recoil value right
now is the value 0-1. That's why we need to
multiply it by some value. For example, -50 because we wanted to go
backwards, right? Just with that,
let's just test it. Head compile, save, go to level, run over game, go forward a
little bit, head of eight. No, let's just go to unt ship. You can see, no,
it's working fine, and it looks beautiful. Just look at it how
beautiful it sounds, right? It looks beautiful. No, we have a recoil
effect as well. But the next thing
that I want to do, I want to add some
sound as well. Right now, it doesn't
have any sound. So in here, I want to span, sound, add location as well. The sound that you want to
spawn is called cannon fire, and the location of it, we can get actor location, that's more than enough, but we don't want to
hear it from far away. That's why I want to use one of the sound attenuation that we create from before,
like explosion, right? That's more than enough. Now, we have a sound. Let's just check that
out. If you go to our level and run over a
game, let's just go to it. You can see when it hit
us, we can hear it. But if we get close to it, we should be able to hear it actually if it
is firing, right? Of course, we didn't
need this sound. But it's good to have it. Let's go backward. No, if you go here, you can see, we can hear it. But if we go backward,
let's just look at it. We can hit a fade to go
there and look at it. If we hit a fade,
there will be sound. In here. Let's see if it should. We can see, you can hear it. If we get close, the volume will be more. Just look at it. And if we go backward, you can see, we won't be
able to hear it a lot. And that sounds really good.
36. 35 Apply damage to antiship: Know what we want to do?
We want to be able to destroy these anti ship guns. Let's see how we can do
that. For doing that, let's go to BP Anti ship. And in here, we want
to create an event for event, radio damage, right? And I want to just show
it with a printer string. We want to destroy it
whenever it gets damaged, so destroy it. Anti ship. I want to make a thread so
you can see it better, right? Now, with that done,
let's just test it to see if this event radial damage
is happening or not. If we run or game and
just zoom a little bit, you can see one
problem that we have, we can shoot down. So that's why we need to modify our BP ship a little bit, right? Wherever we have the
clamp for org to go down, so click on the ship open up the animation
blueprint of it. And if you remember, we had a clamp in here, I want to change
it to minus ten. And because over system, no, it's better, you won't be
able to shoot at over ship. No, you can see we
can shoot at it, and it's not hitting
the ship at all. No, let's see if
we can destroy it. Just barely hit it, right? No, it won't say destroyed. I don't know if I hit
it correctly or not. But you can see
it's not happening. Let me get close to it to see if it actually if we
actually hit in it. I want to get really close to it to make sure that
it's not working? Because it's not
working right now. If we shoot it no, let's see. We can see we are hitting it, but it's not saying that
the destroyed anti shape. What is the problem?
The problem is that this skeletal mesh
collision is not set up. Let's just go down. You can
see it says no collision. We need to change
that to custom. We can tell it to
ignore everything. The important thing is to
make the collision enable to query and physics and change the object
type toward dynamic. The radial damage won't
work with the static. After this, we need to enable generate overlap
events. So check that. No, with that do, let's
just head compile, save. If you go to our
level, you can see, I did change the position of
where players start so we will spawn closer to these anti ship guns
so we can hit them. Now, if you run word game, you can see if I
head close to it, it will say destroy
anti ship. You can see. Again, if I head close to it, it's not close, you can see, it says destroyed
anti ship again. Let's just hit the at
deposits or radio damage. And again, you can see, no, it's easier to hit
it. No, that's it. We are destroying the anti ship, but there is no visual
effects for showing that. Next video, we will add that. We will add a blueprint
for damaged anti
37. 36 Destroy antiShip: No whenever we
shoot or anti ship, it should be destroyed, and we need to create a
destroyed actor. So in here, I want to go to Blueprint folder or anti
ship, right click in here, create blueprint class
of type of actor, and we want to call
it BP anti ship. Damaged. Okay? Don't
click on it to open it. In here, I want to add
estatic mesh, right, and change it to
default syn root, replace it with default sin root by dragging and dropping it. Now, the estatic mesh
that you want to add, it's called SM east
RT, MM damaged. You can see it.
It's exactly that, but it has different
material, right? No, I want to add a
Nagaral effect as well. So add the Niagara effect for us to show that
it is destroyed. So click in here, it's called NS East art damage,
right? Put it there. We can position it
in here like this. No, it looks much better. No, whenever we shoot
at our anti ship, instead of saying
anti shape destroyed, we want to spawn this. So let's just go to anti ship instead of this,
what we want to do? You want to spawn actor
from a class damage. It has damage inside it, until ship damaged, right? The span transform, we can
get the actor transformed. That's it. And after that, we can spawn system
there as well, spawn system at location,
explosion, right? Dust explosion. We can get the location of
where get actor location, right, the location of
this actor and that's it. And after that, we can destroy this untiship as well, right? Destroy it at the end, no let's say that no let's
just shoot at it. And now you can see
it will be destroyed and you can see it
destroy this one. And now you can see this
one is destroyed as well. Who is go back and shoot
at this one as well. And now you can see it's dying. It's working. We
destroyed three of them, and I think the visual effect is working fine,
and it's beautiful.
38. 37 Ship destroyed: No next thing that
we want to do. We want our ship to have health, so we can destroy it as well. So for doing that, I want
to go to our BP ship. In here for the health, I want to create a variable. I will call it health. And the type of it, I
want it to be float. Let's just create
another variable. This one, I want to call
it Max Health, right? The Max health, let's
just had compile. I want to put it
on, for example, 200 and the health, I want to put it on
50 right for no. Just with that, whenever
our ship gets some damage, this event damage will happen. So what I want to
do, I want to get the health subtracted
with this damage, right, with this damage, and set the health
with it, right? Like that and connect the
execution paint here. And after that, we want to check if the health
is less than zero, so we can check it
with the branch. We get the health and less
or equal to zero, right? In this case, we
can use a printers ring to say the
ship is destroyed. So let's just say sp
is destroyed, right? With that, let's just
to compile save. And next thing that I
want to do in here, I want to add
another print ring. So with that, we show
the health as well. So in here, printestring, and show the health,
just like that. Now, if you head
compile every time it will apply damage 25, right? So if you run a game and three
of them will shoot at us. It will be destroyed.
You can see. But I want to change the
position of our ship. After that, I should
go backwards, so it won't be able
to shoot at us. You can see it hit 25. Now, we have just 25. It will hit us one more time. It will be zero, and it will
say, ship is destroyed. Let me test something. The shelf, I want to put it on, for example, 70, right? Head compile and no let's
just test that out. We run our game, go backward. First time that
it is hitting us, it will be 45. After that, when it hit us, just look at it when it hit us. It will be 20 and after that, when it hit us, again, the ship will be destroyed. You see? Everything cool. No whenever the
ship is destroyed, instead of just saying
ship is destroyed, we want to have some
visual effects. So for doing that, I want
to go to content drawer, go to Blueprint and
here right click, create a blueprint
class of type of actor, and I want to call
it BP ship damaged. Okay. I'll click on it
to open it in here. I want to add tatic
mesh, just like that. I want to replace the
default sn root with it. Now, the static mesh that
I want to use is called. There is a damage inside it. So search for damage
SM st ship damage. Put it there and you
can see it over here. No, I want to add a Niagara
effect to it as well. And it's called NS West damage,
let's just put it there. We can add multiple of them. For example, this one, I
want to put it over here. Duplicate it, control
this duplicate it and put it over here,
one more of them. Again, duplicate it one more time and put this
one over here maybe. And now you can see
how it looks like. I think it looks beautiful
when we destroy it, right? Head compiled, save.
No next thing, we want to go to a static mesh, and in here, we want
to simulate physics. So when it spawn, it will sink right? Now, let's see what'll happen. If we compile save, go to our BP ship. Whenever the health
get less than zero, this true will happen, and we want to spawn the
destroyed ship, right? So click in here,
search for damaged. It's called Ship damaged. It needs a transform. We can just get the
actor transform. That's it. And everything
I think is good. But after doing this, we want to destroy
the ship, actually. So destroy actor that's
a heat compiles, Save go to a level.
Let's just look at it. It hitting us. Two of them will hit us. You can see. And
that looks good. Two, next time we
will be destroyed. Let's just say. And now you
can see, we are destroyed. Again, let's just say
that one more time. I want to go forward to looks
more beautiful in here. Now, you can see if they
hit us one more time, let's see what will
happen, and that's it. We ship is destroyed. Now, next thing that
you want to do in this ship damaged
in event graph, we want to set a timer
on its begin play. So set timer by event, right? After, for example,
three second, we want to reopen
the over level. So in here, let's just create
custom event reload level. I will name it reload level. You can name it
whatever you want. And in here, I want to
say open level by name. I want to reopen this level. So let's just put
the name there. New map. No, let's just test that one
more time, compile, save. G here. If they destroyed us, let's see what will happen. Let's go closer, so they
will destroy us much faster. That's it. If they
hit us one more time, and it will be destroyed
after 3 seconds, we will be restarted. You can see, No, our
game is working fine, but we need to show the health
actually for the player. Let's see how we
can do that. Next.
39. 38 Health UI: Now let's see how we can create
a health UI for our ship. For doing that, I want
to go to content Derre, go to Ship folder in
here, go to Widget, go to user interface
in here and create user blueprint of
type of user Widget. I want to call it
DUBP ship UI, right? D click on it to open it. And in here, first and first, I want to go to panel, add a Canvas panel to our
hierarchy, and after that, I want to add a progress board
to it for our health boar. I want to call it
health bar, right? And I want it to be
a variable as well. Next, I want to anchor it to
the left corner like this. I want to add a little
bit offset to the left, so add 50 to position X, right? The size X, I want it to be 20, the offset to top, I want it to be 100, right? And offset to bottom, I want it to be 100 as well. Now you can see this
is our health bar. And now if you change
this percent 0-1, you can see what will happen
if I change that like this, it will go from left to right. Let me zoom in here so
you can see it better. You can see it will go
from left to right. But the bar field type I want it to be from bottom
to top, right. Now you can see it
will fill up this way. At default we want
it to be one for no, of course, next, I want to
change the color to green. So put red and blue to zero, but the green to one. This is our health bar. We can decrease the alpha of
it a little bit like this. We can make it more
dark like this. I think that looks much better. This is our health.
And for updating that, I want to go to graph, and in here, I want to create a function for
updating the health. So I will call it update health. I want to get the health bar, progress bar, and set a
percent on it, set percent. As you know, this
percent is value 0-1, and we want to update
it from outside of this WBPCPI so we can dry and
drop this as input, right? We can just call it in
percent. We click in here. You can see automatically
it put it here, a type of float, right? Now that we have our health Bar what I want to do I want
to go to over ship. And at the begin play, let me find the begin play. It should be up here. We want to create over widget. So create widget, right? And what widget
we want to create it's called WBP Ship UI. And after that, we want to
promote it to a variable. I want to call it ship
UI as well, right. And after that, we want to
add these two viewport, so add to viewport. That's it. We don't need
this PUI to be here. So it will be there. If you head compile, save
and go to our level and run, you can see the health
bar will be there, but we are not updating it. First, let's see how we can
update our health boar. We can get our ShipUI in here, get it, and update
the health on it. There is a function inside that update health that
we created together. No, we have the health right? And we have the max health. If you divide this health, by max health, it will
give us a value 0-1. So for example, if the maxelf is 100 and the health is zero, the percent will be
zero. It's okay. If the health is 50 and
the max self is 100, it will give us 0.5. The percent will
be okay as well. But if the health is 100
and max health is 100, it will give us 1%, and again, it will be okay. Now with that, if
you run a game, you can see the health is
updating successfully. No next thing that
I want to do every time that we
decrease the health, we want to update the
health bar, right? So how we can do it, we can just copy all of this code for
updating the health, control C to copy it
and go down whenever we decrease the health that we done it over here, we
can show it, right? Let me make some space, and we don't need
this printesting, so let's just delete that. Control V to paste
all of those code. And with that, we are
updating the health whenever the health is decreased on
event any damage, right? If you had compiled, save and go here
and run over game, if they shoot at us, let's see what will happen.
They did shoot at us. Now the health is decreased, and if they shoot at
us one more time, you can see the health
will be zero and the ship will be destroyed.
That is working fine. Let's just and I think I
killed two of them, right? No, we need to clean
up a little bit. In anti ship, we have a box line trace that
the debug of it is on. So let's just make it non. No next thing in
projectile for overship. Let me find it. If you
go to Ship Blueprint. Both of these projectile have a draw debug sphere. We
don't need it anymore. We can just bypass it just like this for the other one as well. Just bypass this draw debug. We don't need the
debug for over game, it's just for testing, right? No, let's just run over game. You can see we can't see
if they can see us or not, but we can destroy them, and we are destroying them.
40. 39 Fix bug Radial damage is not working: No, there is a problem.
Let me show it to you. If you go to our level and
in here run over game, let's just go back so
they can destroy us. If we zoom in here and
shoot, for example, here, it should destroy
the anti ship, right? Because we are
heading close to it, but it's not destroying
it unless we shoot exactly there. You see? It didn't destroy again. Let's just shoot it
exactly on its place. Go up a little bit like this. And again, it's not destroyed. Again not destroyed. It's like we can't
destroy it at all. It's like it's not happening
at all. What is the problem? This is like a bugging
Aerial engine, but we will fix it. So in here in the projectile that we use whenever
we had something, we did use impact point, right? But if you change this impact
point to impact location, if you use this location there, this will fix our problem. You know, Runo game, and if we head close to them, it will get destroyed, you see? Now, in here, if you
head close to it, for example, at back of it, just go up here. You can see it did destroy it. So that was the first problem, the big that we fixed together. If you find any more big, you can just leave it in question section or in
this coord channel, I will create a video for.