outdrive
we are back and ready to start building out some in the actual gameplay
in our game and that's gonna begin by creating
and enemy character the weekend interact with so let's start off by going back to
our C plus plus classes jumped and or twin stick shooter folder
and here's our base character c plus plus class once again
I want you right click on that go over to create
blueprint class based on base character
click and we're gonna name this one
an army character such creative name Drake
now won a place that in the blue prints folder as well
click on the create blueprint class button wait a second and it magically
appears
so well it's drag this up to the top in adjuster panels when can I see all the
different bits and pieces again
we do have our summer the same stuff we do with the hero to do so let's elect or
mash component
we will and the SK manikins skeletal mash
and will place this inside the capsule just like before
and rotate that ninety degree so it's facing former
now I don't want the enemies to be the same color as the hero that's going to
be confusing
just too much to look at so let's figure out
how we can change that color if we take the skeletal national double click it
that's gonna open this colossal mash up in Persona
and it's going to take us right to the mashed ap so we can pan around them and
see how
awesome this character looks and he does look pretty cool not gonna lie
but we can also see the materials that are applied to
and there to love them there is that the you reform and
body and reform and chest logo which is
actually yes the should be in instance Arvada
the top on so let's take the arm and body your uniform and body material its
DoubleClick that now open that up
material under now there's not that much going on here it's really just blending
together a few
layered materials that you have some areas that look like Nadal
and dark grey plastic in this
days plastic which kinda dominate the whole character will
that Bayesian color is a is better Preminger
and it's named body-color so if we make a dynamic version at this material
and we change body-color we can thereby change the color I love this entire
character which is pretty cool
but note the spelling there its body color without spaces matter fact
I'm gonna selected here inside the details dental and it controls
sees I don't have to actually typing leader now let's go back over to our
enemy character
let's go straight to the construction script I'm gonna drag
a reference to that skeletal mash here into the construction script
rehab now if you drag a wire of this what we need
is a dynamic version up the material that's applied to
index 0 how do I know it'd index here what we jump back over
to persona notes with element 0 an element 1
11:00 is the main material element one is the little chest logo which is just
giving us
the little you re for logo that you see here were taken some
right up on so let's not jump back out
struggle wire of and I want to just take the word
dynamic her if you can spot dynamic I apparently can't
I was so there's create dynamic material instance
now this is Kennedy do it all at once node I love this nude
what this is doing is it's grabbing whatever material was found
in element index 0 it is converting over to a dynamic version so that you can
change
any parameters that are found inside it and then once its done that it really
applies it back to that same
element number so will connect that up
and then we just want to do I are we could set this to a value
you know let's do that nothing will ever use at less do anyway let's take this a
new dynamic
material we just created promoted to a variable and we're gonna name it
Dina
then
after we done take the return value that new
I'm variable drag a wire of it and see
set vector parameter value
like so now this is going to ask you
what primary wanna talk to remember earlier we copied
body-color so control V there it is body-color
no spaces but what color we gonna send it to
well this is where you just decide what color you want your an immediate be so
let's go with some shade
a red sick animal arms too bright pregnant
eg so just screams danger
and if you take a look over in the the ports actually
compile look over the port he turns
bright red which is pretty cool I now if you want to
you can right click on that value promote that to a variable
and call this and any color like so
and so now if you take a look at the viewport you could go over to
enemy color and in the if you compile this you can now go over the details
panel
and you can set this any shade you want so you enemy can be
anything he could be bright yellow if that's your thing
are or he could be orange or on a plane back to read
will just lead I will decide at rated just a little bit
there you go said look super dangerous now you'll notice
this is not changing the color the logo that's fine
I will just leave it as a a nice little white logo on his chest or
beige logo whenever but now we've got a nice visual I differentiation between
our hero in our enemy some issue that should make it a lot easier to tell one
from the other
on the screen which is great now with that done
let's setup the controller
the AI controller that is gonna drive this
enemy around now I'm only doing this cuz we're only like six minutes into this
video
and it's such a simple thing that I didn't really want to put it off into
its own video to be really really short
cell I to set this up let's go back out to our content browser
and
and let's sell right click hearings on a blue prints folder
and let's make a new blueprint class we want to base this
offered AI controller which does not appear in our common classes list
to find a I controller need to click on all classes
and its easiest to just search that the search for AI
controller you'll see it really quick select AI controller and then click on
the green
Select button listening this enemy
AI and will open it up
as just a blueprint like any other cell
has all the same panels will put us all back like they were and come over to the
event graph
now it's got some components to help it do some stuffs right so it's got
a transform component it's got it passed following component which is gonna make
use a nap mash
and then actions on a comp are actions component which gonna be used for a
for various I behaviors now this as I mentioned
is going to be a very very simple
AI controller so bledsoe right click
and let's make a custom event
we're gonna call this event track
player as all gonna do
or you could call chase player track player hun player whatever
I told me the same thing and what it's gonna do is a special function
called AI move to what this does is this takes upon
and tell that to move toward a destination or toward a target
actor and once it gets within the acceptance radius it stops
the nice thing about this is it will keep hunting it'll keep moving the pawn
toward that target actor
until it hit the acceptance radius meaning we don't have to call this node
very often
in order to have something to chase is our player pretty much all the time
we do need to feed at the pawn that is being driven
and we need feet at the target the pawn is being driven is
pretty easy we can just right-click since this is the AI controller
this controller will be plugged like a cartridge into the sidebar
our enemy characters head which at a metaphor that's
not really how it's gonna
there's no cartridge hang upside his head go with me let's right click
and see get control upon
so that is literally a reference to the pawn
this I controller is controlling and will plug that
into pot alright
next we need the target actor for this let's say
gets player character and there it is
to get the player character and that becomes the target after
that's all we need to do we just need to use their so now
when I whenever this is called the enemy will just move toward the hero
until it gets within five units in five minutes is fine we don't need to change
that
however we do need to have something that keeps
calling track player over and over just he's picking hey
keep checking the player keep checking the player because if we ever get within
this radius
this hey I moved to will stop firing and then I'll never chased the player again
if we don't explicitly tell into to do that we are going to you
set a timer a timer is released
it's actually just like the timer on a camera there will be a countdown and at
the end the countdown
is going to call some function and you just type the name in the function
right inside here so we're gonna tell it to call
track player how often do we want to track it well let's do it every
one second and this will be looping so it's gonna keep calling
every second now when do we had noticed this is not an event right we need
something that's gonna
called it something or plugin to this execute a bullpen
so let's grab begin play
what this means is the moment this AI character spawns or the moment the game
begins
this set timer will be called and that is going to keep calling track player
once a second keep telling the hey i'd chase the player
over and over so it's compile
let's save then we're gonna take are enemy character
and said a few things up so let's go into it class
defaults and we are going to come down to the
AI controller class property and we can set that too
enemy AI like cell compile and save
now watch this we take our enemy character
and Dragon in the world and then hit play
actually nothing's gonna happen yet let's just move over to him
is just sitting here being boring so his behavior is actually there he's got me
in the the requisite microchips in his hand so to speak
to make a move around we doesn't have yet is
and navigation mesh and navigation measures are super easy to do and
unreal watch this governor volumes Anderson in the place in browser click
on the volumes category and you should find
the now mash downs volume drag that on your floor
now this needs to penetrate down into the floor some move it down a little bit
and then grab your steel tool just gala doubts were completely covers the floor
and hit the P key to visualize your mash
and there you go there's a navigation ish
already done so again super super easy so now if we hit play
oh my goodness the he so fast
we can get away from him that's that's actually kinda ridiculous we need to
slow him down
so would stop playing let's go to you
our enemy character local right into the movement component or character moment
component
and let's grab the max walk speed I'm gonna pull that down to you
IRC she to
and read that apply make the game too easy but you can always tweak it later
soul compile and save now will hit play and there you go
he is just chasing us and he'll keep right on chasing us
over No if he touches us he'll wait a second then Hill go again
so there you go we have
and any with his own little AI that is just chasing the player
which is pretty awesome so let's go ahead and get outta here
that is going to wrap things up for this video
thanks a lot
for