Welcome back.
Now our projectiles are looking pretty good, but we do have a couple minor issues, specifically with
collision.
If I just hold shift and click over here, you'll see that my fireball hits one of our potions.
And not only is the potion consumed, but the fireball explodes.
And neither of those are what we want.
Now, if you've done any playtesting, you'll probably realize that the projectile will go straight
through some things and not collide with them at all.
So we need to sort out our collision for our projectiles.
Now, in the case of this pillar here, really all we need to do is make sure that the pillar generates
overlap events.
So if we search for, generate and check, generate overlap events on our pillar.
Then that right there should solve the problem of not blocking or overlapping with our projectiles.
But what about this whole business of projectiles hitting our pickups?
Well, our pickups are set to overlap with certain types, certain object types, and our projectiles
are set to overlap certain object types.
And if we look at our firebolt and check out our sphere, we'll see that the sphere is a world dynamic
object type and it's set to overlap with world static, world dynamic and pawn.
But most of the things in our world are either world static or world dynamic, including something like
our potion.
If we edit Mana potion, for example, we can take that box and see its collision object type.
If we expand Collision Presets, it's a world dynamic, so we need another collision object type that
we can distinguish from world static and world dynamic.
Those are most of the things in our world.
But I think something like a projectile object type would be great because then our potions and other
pickups can ignore that object type, whereas certain other objects can block or overlap it.
So we're going to make a custom object type, and we do that by going to edit and project settings,
and we can simply search for object and we have object channels.
And if we select new object channel, we can give our new channel a name and a default response.
Now for the name we're going to call this object type projectile.
And the default response for it could be ignore, overlap or block.
Now our projectile is made to overlap with things.
It's never really going to block anything.
Now those things it does want to overlap with are namely world static, world dynamic and pawn everything
else it's really going to ignore.
So by default we can set its response to ignore and then manually set any components that have this
type to have responses to the other types that we choose.
So I'm going to go ahead and call this projectile default response, ignore and accept.
Now, it's handy to be able to access this collision response channel in C plus plus, and for that
reason I usually go into C plus plus and make some kind of constant or macro symbol that represents
this.
So what I'm going to do real quick is just save all and close and back here in the editor, I'm going
to go into my aura dot h and here in Aura H where we defined our custom depth read symbol, we're also
going to define our projectile collision channel.
So we're going to use a define.
So pound sign, define, and I'm going to call this EQ for a collision channel.
We're going to call this projectile.
And what we're defining it to be is a collision channel, EQ game, Trace Channel one.
And that's because when we create a custom channel for the first time, it occupies Game Trace Channel
one by default.
If we created another one, that next one would be Channel two.
So now we have this EQ projectile and we can choose to ignore or overlap with it.
Now our aura effect actor should ignore this channel by default.
So what we can do is for our overlap volumes that we add to our effect actors, we can make them ignore
this channel.
So I'm going to go ahead and compile and run this.
And back here in the editor.
I've got my mana potion still open.
I can take its box component and for its collision presets we can set this to custom and then I can
ignore the projectile which it's set to ignore already because we made it a default ignore response.
So really anything we want to overlap with it, we have to manually set that to overlap such as our
pillar here.
If I search for collision, let's see what we've got here.
We've got collision presets and projectile is set to ignore, but we want to overlap with it, so we'll
check overlap.
And now we can go into our firebolts and select our Firebolts sphere component.
And down here in Collision we see that it has its object type set to world dynamic.
This should be set to projectile, but we should also set this on the C plus plus side as well.
So let's go to Aura Projectile CP and up at the top we're going to set the collision object type here.
So we're going to say sphere.
Set collision object type and it's going to be XY projectile.
Now, as soon as I did, this writer included Aura dot H, because that's where this is defined.
So make sure you include that if you're using XY projectile somewhere.
If you don't have auto include like this.
So now our sphere is set to the projectile.
Now we did set this in Blueprint as well.
So next time we compile that C plus plus change will take effect.
But I set it here in the blueprint, so we're covered there.
So now we should be able to ignore those potions.
We should be able to go straight through them.
Like so.
But we do want our enemies to block, right?
We don't want to go straight through the enemy.
So we do want the enemies to block the projectile object type.
So for that reason, we can go into character and enemy base where we can take our enemy's mesh and
scroll down and make sure that it's set to overlap the projectile.
And this is something that our base character should also have set in C plus plus.
So we'll go to character or a character base where we're setting our mesh collision response to the
camera channel to ignore.
We should also set its collision response to projectile to overlap.
So we'll say git mesh.
Set collision response to channel and the channel will be e cc projectile.
And again we got ora h included there and the response will be e cr overlap.
And now all enemies should overlap.
And if we want, say, PvP, then two aura characters playing in multiplayer together, shooting fireballs
at each other.
They will also be overlapping the projectile type.
Now, if we go back into the editor and we launch a fireball at an enemy, we expect that fireball to
blow up.
But we see that it does not.
And that's because we also need our mesh to generate overlap events.
So if I check that now, if I launch a fireball at the enemy, I expect to see it blow up and it does.
So this is another important property that we need set and it should also be set in C plus plus.
So again, on a character base, we're going to take our mesh.
So get mesh and we're going to set generate overlap events.
So call set, generate overlap events passing in.
True.
And again, next time we compile that change will show up in the editor, but we set it in the blueprint
as well for BP enemy base.
So now we're getting more along the lines of the behavior we want.
We can launch a fireball.
It'll go through all pickups.
It's not going to generate overlap events for them, but it will hit our enemy and blow up on the enemy.
And that is exactly what I wanted.
Perfect.
So now that we've sorted out collision for our projectiles, we can continue.
I'll see you in the next video.