Welcome back.
We're continuing with Fireblast, and in Fireblast I'd like to call our blueprint Callable function
Spawn Fireballs.
We made this blueprint callable function.
It doesn't really do anything yet.
That's what we're going to change in this video.
Notice it returns an array of fireball object references for our convenience.
What we need to do is actually spawn some fireballs.
So we're going to close the editor down and go into aura Fireblast to implement this function.
Now I'm going to go ahead and close out of Aura projectile as well.
And here in aura Fireblast let's start thinking about how we're going to do this.
Now I'm going to want to spawn 12.
I say 12, it's a variable, so we could change it, but I'm just going to say 12 of these fireballs.
And I'd like them all spaced out evenly and to go out in all directions.
So we have a nice function to calculate evenly rotated rotators or evenly spaced rotators.
If we go into Aura Ability System library, there's a function to get those rotators that I need.
And that would be.
Evenly spaced rotators.
I'm going to call this function.
So here in our fireblast I'm going to go ahead and just move that down.
And I'm going to use you or ability system library.
Evenly spaced rotators and see what this needs.
Now it needs a forward vector.
So I'm going to need to get my avatar actors forward vector.
I can make a const f vector called forward, and I can get avatar actor from actor info and call get
actor forward vector.
If I want to do that, then I don't have to pass this big huge thing in.
I can just pass in forward.
Now it also needs an axis, and the axis is going to be the up vector.
I don't see any reason to spawn these out in any direction other than parallel to the ground.
So I'm going to use f vector up vector.
Now we need a spread.
And if I want evenly rotated rotators all around Ora, then the spread is going to be 360 degrees.
So I'm going to pass in 360.
And the number of rotators is going to be my variable num fireballs.
So I'm going to pass that in.
Now this function is going to give me in return a t array of f rotators.
So I'm going to store that in a local variable called rotators.
And after this I have evenly spaced or evenly rotated rotators and I can loop through rotators.
I can say for const f rotator, reference rotator and rotators.
And for each rotator I can spawn a projectile.
So this is great because now I can spawn a projectile and give it a rotation, and that's going to already
be pointed in the correct direction.
So let's go ahead and spawn some of these.
I'm going to create an A or a fireball pointer and call this fireball and use spawn actor deferred.
So get world spawn actor deferred and use a or a fireball as the class.
And we need to pass in the class to spawn.
That's going to be my fireball class.
Now it needs a spawn transform so I can go ahead and calculate an F transform.
We'll call it Spawn Transform and I can take Spawn transform.
And set its location.
So where do I want to spawn this fireball?
Well, I want to spawn it at my avatar's location, so I'm just going to cache off that vector up here
at the top const vector location.
And it's going to be get avatar actor from actor info get actor location.
Just because that's a lot to type and I'd rather just pass in location here.
Now for the rotation.
We're going to use our rotator.
So we're going to say spawn transform dot set rotation.
We're going to use rotator.
Now this does have to be a quaternion.
So we can call quaternion there.
And with that we can pass in our spawn transform.
Now for the owner we can set the owner of this fireball to be the owning actor from the actor info.
So we can call get owning actor from actor info and pass that in.
And at this point I'm going to start putting these on their own lines.
And the next input is going to be the instigator.
And that's going to be my avatar.
So that's how I'm going to define those inputs.
And after that we need a collision handling override I'm always going to spawn.
So I'm going to use e spawn collision handling method.
Always spawn.
Now spawn actor deferred is complaining because it wants a pawn here, so we can't just pass in an actor.
But that's okay.
If you want, you can pass in null or you can get the current actor info, not activation info, but
current actor info because here we have a player controller.
Player controllers have the function get pawn so you can get the pawn from the player controller like
that.
No problem.
Okay, so we're calling spawn actor deferred.
After we spawn the actor deferred, we need to set the effect parameters on this fireball, which means
we need to make some effect parameters so we can call make damage effect params from class defaults.
And we don't have a target actor.
That's something that we have to take into account when our fireball overlaps with something.
So we have to pass in null pointer for that.
We also don't know the radial damage origin and we don't have a knockback direction to override, nor
do we have a death impulse or a pitch that we'd like to use as an override at the moment.
So what we can do here is just pass in no params, and we can go ahead and store this in an f damage
effect params.
We'll call this effect params.
Actually we'll call it damage effect params.
And we can set this on our fireball.
So we can say fireball damage effect params equals damage effect params.
And in fact this intermediate local variable is unnecessary.
We can just call the function.
Now with that we're just about ready to finish spawning, but we can go ahead and create an array that
we want to return from this function and add this newly spawned fireball to it.
So if we'd like to do that, we can create this array at the top T array A or a fireball.
That's pointers.
And we'll call this fireballs.
And we can add fireball to it.
Fireballs dot add fireball.
And by the end, we can return fireballs.
And with that, we're now ready to finish spawning so we can call fireball.
Finish spawning.
Passing in.
Spawn.
Transform.
And with that we have a function that will spawn our fireballs.
So I'm going to restart the editor.
And get my ability back open.
So here's BP fireball, here's my fire blast ability.
We're calling spawn fireballs.
And really we can just give this a try.
So I'm going to go ahead and save all.
Press play and press the two key.
Now we can't tell.
But there are 12 of them.
There should be.
But really, there's no way to know unless we move them somehow.
Now we do have the projectile movement component.
So really, if we did add some initial speed and max speed, we could see them fly out.
So giving them that speed and then we could come back and change some of these properties like auto
activate.
And we could start with tick enabled.
And now if we launch, they go out.
So it looks great.
And we can even see what it looks like with a higher velocity.
Say 1200.
Pretty nice.
And just because I can, I'm going to set it to 1600.
Nice.
Very nice.
Now this is great, but I want those fireballs to come back and I want them to explode when they come
back.
So that is what I'm concerned with next.
And after that, we're going to want them to also cause damage to anything that they come into contact
with as well.
Excellent.
Awesome job.
And we'll continue in the next video.