Welcome back.
Now that we've got things working pretty well and we have a test ability, it's time to start actually
giving our abilities something to do as our test ability only prints debug messages to the screen.
Now if I click just anywhere, I'm going to move to that location.
But if I'm hovering over an enemy and I click, well, I activate my test ability.
So that's great.
We know that we can activate abilities and everything, but I'd like Aura to have some magical spells
that she can cast, and that's going to require some real abilities that do real things.
So the first spell that I'd like to make is a projectile spell.
I'd like for Aura to cast a projectile like a fireball.
And if we go to assets and characters or animations abilities, we have a cast firebolt function.
It looks like this.
So we have an animation that we can play.
And if we're going to cast a firebolt, we need a firebolt effect.
And if we go to assets, effects and projectiles, we have this firebolt and there are three versions.
If we open them, I'm opening fire.
Three you'll see that this is what they look like.
They look like fireballs.
Pretty exciting.
So I'd like to launch one of these and that is going to be our first major ability.
And this happens to be an ability that will require quite a few different aspects and mechanics to it.
So this will be a great learning experience for how abilities work now, because we're going to want
to spawn projectiles.
We need a class for a projectile to spawn and we're going to create a projectile class in this video.
So let's go ahead and do it.
We're going to go into our C plus plus classes or a public actor folder.
I think we can put this right here in the actor folder.
It's going to be an actor.
So let's make a new C plus plus class based on actor.
Click next and we're going to call this aura projectile.
Let's go ahead and create this class.
And I'll close the editor.
And in this aura projectile class, we're going to put some basic things that we need.
So I'm going to go ahead and close all the tabs and open aura projectile dot h and we can start to sort
of rearrange this basic actor.
So first of all, I don't plan on using the tick function, so we're going to remove it altogether.
I'm also going to remove these comments as I don't feel like we need them and I'm going to go into the
CPP file and remove tick from here, remove the comments as well and set primary actor tick be ever
tick equal to false in the constructor so we don't tick.
And without those comments we're stripped out and it looks clean.
So what do we want in Aura Projectile?
Well, we want to be able to hit something.
I'd like to use overlap events for this and what we saw with our Effect actor is we could add that overlap
volume in blueprint and we wouldn't really need access to it in C plus plus as long as we created a
blueprint callable function that we could call from the blueprint and pass in any important information
such as the actor that was overlapped.
We can take that approach here if we'd like and then leave it up to the blueprint side to add that projectiles
overlap volume.
If we want to do that, another option is to just add it here in C plus plus, if we know it's always
going to be, say, a sphere, if we don't think we'll ever need a projectile that has a box or capsule
collision volume, we could just add a sphere right here so we could do it that way.
I'm going to do it that way for the projectile.
I think all of our projectiles are going to want a sphere overlap volume.
So I'm going to make a private section and I'm going to add a T object pointer to type U sphere component.
I'm going to add a forward declaration for it and we'll call this sphere and it gets a U property.
With visible anywhere.
Now we'll create an en overlap function for it.
So let's make a void function en sphere overlap which we'll need a u primitive component pointer called
overlapped.
Component.
An actor called other actor a you primitive component pointer.
Called other comp and in 32 other body index, a bull called B from sweep and a const F hit result.
Reference called sweep result.
And this must be a new function.
So let's create that function definition and we're going to construct our sphere component and then
bind our on sphere overlap to it.
So first we'll construct it here in the constructor sphere equals create default Subobject use sphere
component.
We'll call this sphere.
We'll let the root component be the sphere.
So let's set root component to the sphere.
And now that we have a sphere, we'll go into begin play and say sphere on component.
Begin overlap.
Add dynamic.
With this and or a projectile on sphere overlap.
Great.
Now my sphere should be set to query only.
So I'm going to say sphere set collision enabled to collision enabled query only.
And I'm going to set it to ignore all channels except for the select few that I want it to overlap with.
So we're going to say sphere.
Set collision response to.
And I want it to be to all channels and I'd like to use ECR, ignore collision, response, ignore.
And then I'd like to set collision response to specific channels.
So set collision response to channel.
I'm going to choose EC World dynamic.
We'll go ahead and overlap that.
So ECR overlap.
And I'm going to copy this line and paste it and change this to make world static.
We'll overlap those and I'd like to overlap with the pawn type as well.
So EQ pawn will overlap those as well.
Okay, so now we have a sphere.
It's got an overlap callback and this is a projectile, right?
So it needs a way to fly through the air.
The perfect way to handle that, especially in multiplayer, is with the projectile movement component.
So we're going to add one of those as well.
I'm going to go ahead and forward declare that right away.
And the type is you projectile movement component and I can foresee myself needing to access this from
outside the class because in the future we're going to want to set parameters on it.
Potentially, we may wish to make it a homing projectile and set its homing projectile target, things
like that.
So I'm going to make this a public component.
It's going to be a T object pointer of type U projectile movement component called projectile movement,
and it's going to get a U property with visible anywhere.
And just like our sphere, we'll construct it right here.
We'll say projectile movement.
We'll use Createdefaultsubobject writer is quick to give me lots of autocomplete stuff, but I want
create default subobject with you.
Projectile.
Movement component.
I'm going to call this simply projectile movement.
It tried to include navigation system types there.
No, thanks.
And we're going to set a initial speed.
So projectile movement, initial speed.
We'll go ahead and give that a default value.
Let's give it 550.
We'll take projectile movement.
Max speed will set that to the same value.
550 and gravity scale.
I'd like this to have no gravity, so I'm going to say projectile movement, projectile gravity scale.
I'm going to set that to zero so we have no gravity.
Okay.
So we have basically a skeleton for a projectile class and we have something that will happen on overlap,
basically an empty function that does nothing.
But we'll definitely be fleshing this out with things that should happen, but we can go ahead and create
one of these.
Let's go ahead and compile and launch.
And now that we're in the editor, we can create an aura projectile.
Now we have our aura projectile class.
But I'm going to make a blueprint based on this that's specific.
I'm going to make a fireball class.
Now, I could put it here in my actor folder, but this is going to be related to one of my gameplay
abilities.
So what I'm going to do is go into gameplay abilities here in blueprints, ability system, gameplay
abilities.
I'm going to make a new folder and I'm going to call this fire and I'm going to have all my fire abilities
in this folder.
And here in Fire I'm going to make a folder called Firebolt and Firebolt is going to contain my Firebolt
ability once I make it.
And any associated classes such as the Firebolt class, that's an aura projectile.
I'm going to make that blueprint for the aura projectile now.
So I'm going to base this on Aura Projectile.
And call this BP underscore firebolt.
I'm going to open it up and here's my firebolt.
And the first thing we're going to add is a Niagara system.
So I'm going to click on my sphere, click Add, Type Niagara and get a Niagara particle system component.
Call this fire effect and set its Niagara system asset.
I'm going to search for fire and choose Fire three.
And there's my beautiful fireball.
We're going to call this a firebolt, actually.
And this looks great.
Let's see what it looks like here in the world.
I'm going to just drag one in, raise it up a bit.
So here's what it looks like in the world.
But of course, it has a velocity, so it's going to fly away, right?
Let's put it right in front of our character.
Oh, there it went.
I don't know if you saw it.
It was a bit quick.
I'll put it over here to the left a bit.
Let's put it behind the character.
And there it goes.
There goes that fireball.
Beautiful.
All right, so we have a projectile, and whatever direction it's facing is going to determine where
it flies.
If I move it that way a little bit and press play, it's going to fly off that way if I turn it this
way.
It's going to fly that way.
You get the point.
So we have something that can fly.
Beautiful.
So now that we have a projectile, we can create an ability that spawns these projectiles, a kind of
fireball ability, a nice, offensive, magical attack that aura can use.
So I'd like to do that in the videos to come and figure out how we can spawn projectiles when we activate
this ability.
So we'll do that in the videos to come.
And before I wrap up just because I can, I'm getting a little tired of my checkered floor, so I'm
just going to go ahead and go into my assets dungeon folder and find a couple of tiles and I'm going
to get some tile one by one A and some tile one by one.
B Let's see if there's a two by two and three by three.
I think I have three by three.
A That's a bigger one.
Three by three B.
And I think I'd like to just.
Kind of cover this floor.
In fact, I'd like to kind of get rid of this floor here and use these.
If I open and show simple collision, I see that they have collision volumes.
So I'm going to take some time to put some of these floor tiles out.
And when we start the next video, you'll see that I have a much nicer floor.
Excellent.
I'll see you in the next video.