Welcome back to your next quest.
You're going to spawn the rock projectile.
Now, from the ranged attack, go ahead and spawn the projectile.
And as a bonus, add a little bit of a spin to the rock as just a flying rock.
That doesn't spin, doesn't seem very convincing.
So add a random spin to the rock any way that you know how, and then see if you can launch some of
these rocks.
So pause the video and conquer this quest now.
Okay, so instead of drawing a debug sphere, I'd like to spawn a projectile.
Now, because my projectile spell has this blueprint callable function spawn projectile, I can just
call that.
Now it needs a target location and luckily we have a combat target and we can access that with get combat
target here.
So I'm going to take these two nodes and just control D over here with those selected to get that combat
target.
And we're going to spawn the projectile.
Now, actually, we didn't need our combat socket location as spawn projectile gets that for us, but
we do need to know which direction to shoot that projectile, which is why we need that combat target
and we're going to get its actor location and pass that in to spawn projectile.
Now let's see if our enemies are launching rocks and it looks like they are.
It's a little bit hard to see those rocks.
Looks like they're actually hurting each other as well.
So that's something that we want to take care of, don't we?
But we're launching something it's a bit harder to see.
So I'm going to go into my X testing map, which has a lot less stuff in here, and I'm going to set
my game mode override to BP or a game mode.
I'm going to remove the Aura character and drag in a player start.
So going to all classes, scrolling down to player start.
Dragging that in.
And I'll go ahead and drag in a goblin slingshot just to see if it's going to shoot at me.
So we'll go to character Goblin, Slingshot and drag one of those in like so.
So saving all.
I'm going to press play.
And let's see if that goblin slingshot.
Looks like it's coming straight at me, so I'm going to check its character class and it's set to Warrior,
so we should set it to Ranger.
That way it knows it's a ranged attacker.
Then it's going to work.
Okay, so it's launching something I seem to only see really its shadow though.
But let me pause the video and zoom in to make sure.
No, it is indeed a rock.
It's just a little small and kind of hard to see.
So there are things we can do to fix that.
Of course, we can make the rock bigger if we wanted to do that.
That's one thing I think I'll definitely do.
So I'll take my rock mesh and I'll set its scale to.
Let's try to.
And we'll try a rock that's twice as big.
Now that looks comically big, so we'll zero in on a good size.
Let's do 1.25.
That might work a little bit better.
I think that's a pretty good size for a Slingshot rock.
Now, in addition to that, we could just make it easier to see by going into that rocks material.
So why don't we do that?
I'm going to browse to Slingshot Rock, open that material, and we could give this a little bit of
some emissive ness and emissive color of sorts.
We could even make it emissive closer to the edges.
I'm going to go ahead and find my slingshot rock static mesh, select it, and then choose to use that
as my preview mesh here.
And I'm going to right click and type for now.
E.
S n l.
This is a nice effect that gives us some kind of glowing edges a bit.
And if I drag that into a miss of color, then now our rock has some glowing edges.
Kind of a nice, easy little trick you can do to make things a little bit easier to see.
Of course, you have to be careful because if it's a white background, it makes it even harder to see.
So it's really up to you, but we can try that also.
I don't think I even applied that material.
Let's try after applying it.
So yeah, it's a little bit probably even harder to see, but we can take that for now and multiply
by a color.
So using a multiply node, I can press three and hook that up and that's a three dimensional color.
We could give it a little bit of a more yellowish or gold color if we like.
And hook that up to the emissive color.
Make it a little bit golden.
Sort of.
And see how that looks.
It's a little bit a little bit easier to see a little bit.
Now, we can also overdrive the color if we wanted to do that by multiplying it by a scalar.
So say 2000 would be a very extreme example of this, right?
So that's going to definitely make it easier to see if we apply and try this out.
But we don't really necessarily want a red hot rock, do we?
But, you know, you could find some kind of balance, right?
You can set this to 500, for example, maybe even 100.
That might even be too much.
You could try 50, maybe 20, maybe even just five.
It's up to you.
But these are just some little tricks you can use.
Five makes it not quite enough, I think.
So find that balance.
Find the color you want as well.
So this can be a sort of brownish color if you want.
So something like that.
And of course, as we get our level in place, then it's going to look even better if we're in a darker
environment.
So if I come over here into the shade, see if I can even.
Get shot at here.
Yep.
There it was.
You could see it a little bit better in the shade, so.
Little tricks you can do.
I'm going to change the exponent a bit.
We'll go up to about 20 and 0.01 for that base reflect fraction.
So that way we'll get more on the edges, less on the inside like so and I'll just go ahead and just
play with that color a little bit, maybe make it a little red ish until I get something that looks
a little easier to see, but I don't want it to be too crazy.
Think I'm okay with that.
Okay, cool.
Now for the random spin.
We could do this in a number of ways.
I'm simply going to create a yaw pitch and roll and get a random float and set those and begin play.
So what I'd like to do is use random float in range.
And we'll go from -360 to positive 360 and promote this to a variable.
And I'll call this your rotation rate.
In fact, if this is a rotation rate, we don't have to stick to 360.
I'm going to go from -500 to positive 500 and I'm going to promote this to another variable and call
this pitch rotation rate and promote this to another variable and call it roll rotation rate.
So we'll go ahead and set these all three and begin play.
And I'm just going to add a local rotation to the rock here in Tick.
So add local rotation, we'll use the rock mesh.
And for delta rotation, we'll just multiply delta seconds by each of our rotation rates.
So I'll just go ahead and get them all out here and multiply each of them.
So multiply.
We'll multiply the first rotation rate by that.
And for Delta rotation, it's a rotator, but I'm going to split the struct pin and use this first one
your that's going to go into delta rotation.
Your it doesn't really matter which one is which here, but I'm going to do the same for the other two.
Pitch rotation rate will be multiplied by delta seconds that will go into the pitch and roll rotation
rate also multiplied by delta seconds.
That will go into Delta rotation roll.
And if we like, we can order these so we don't have too much crisscrossing going on.
We're going to have some, but I can eliminate the criss crossing here.
Like so.
And with that, we have a rock that will rotate randomly.
And of course, it's so small that you probably won't notice it.
So it may be worth it.
Just not taking it all.
But there we go.
We have a random rotation to the rock.
Okay.
Now the last thing I'd like to take care of is these rocks are hurting other enemies.
We want those rocks to just ignore all the enemies and go straight to aura.
But I don't want to just check for aura.
I want to make sure that it's not trying to hurt something if it's friendly to that particular objects
team, so to speak.
In other words, we should use our aura ability system library function.
Where is it?
It's called is not friend.
We should check that and I'm going to check that in our aura projectile as it overlaps.
So we're going to go to Aura Projectile and go down to the on sphere overlap and we're going to check
that right away.
We're going to check if you aura ability system library is not friend.
We want this to be true.
Otherwise we should not do anything on sphere overlap.
Now we need to pass in the effect causer that we can get from our damage effect spec handle like we
did up here.
We're making sure that the thing overlapped is not the effect causer here.
We can also get the avatar from the effect context, can't we?
So there are multiple ways.
I'm just going to use the effect causer.
We're going to pass that in as the first actor.
The second actor is going to be the other actor.
The actor being overlapped.
Now we want is not friend to be false.
If we want to return, we want it to be true.
If we want to cause damage and do everything else now, yes, we're using this damage effect spec handle
data, but we're checking that pointer before and returning early before that so we can use it safely
here.
So if is not friend is false, then we'll just return.
And this should prevent any enemies from damaging each other with projectiles.
So let's go ahead and just launch again and make sure those slingshot enemies are not hitting each other
with their rocks.
And in turn, we can also make sure that Ora can damage the enemies.
And keep in mind, this is now going to prevent PvP because now Ora cannot damage other auras because
they're both going to be players.
So just something to keep in mind, but let's try this out.
Yes, we can damage enemies.
Can enemies damage us?
They can.
Are they damaging each other?
No, they are not.
And that is perfect.
All right.
And I'm also noticing that those rocks are kind of flying a little bit low.
They're hitting the ground before they reach Ora in some cases.
So it is possible that we may wish to have some kind of a pitch override for that initial direction
for spawning the projectile here in ora projectile spell.
So that's something to also keep in mind.
We may wish to angle that projectile upward a bit in the case that it's using gravity.
So we'll get to those fine tweaks as well.
But for now, we know that our slingshot enemies are firing projectiles.
This is looking great.
The only thing left is to make that slingshot actually stretch and look like a real slingshot should
when enemies are shooting.
Excellent job.
I'll see you in the next video.