Welcome back.
So now that our eye is moving around, we've uncovered a couple of things that we may need to fix now.
For one, they're interacting with our effect actors, which means they're picking up our pickups.
And those pickups are for us, not for the enemies.
Now, on top of that, some of the effect actors are affecting the enemies in ways that perhaps we do
like maybe we do like that that fire is causing damage to those enemies.
That's kind of cool.
So we're probably going to want our Effect actors to be a little bit more configurable so we can set
a setting that determines whether or not those effect actors should affect those enemies.
That's one issue.
Now, another is that our enemies are kind of snapping in their rotation.
Notice as I run circles around them, they're snapping and that should be more of a smooth transition
in their orientation.
And that's actually a pretty easy fix that I'd like to take care of now before moving on to our effect
actor.
So let's go into our enemy base class, and I'm going to search here for use controller.
And notice we have use controller rotation.
Your the controller is actually going to orient in the direction that our eye is telling these goblins
to move.
And that happens as a result of the move to task in our behavior tree.
If we uncheck that, however, and press play, then let's see what happens now.
Well, they're following us, but they're not orienting towards us at all.
So what I'd like to do instead is have the character orient in the rotation of its movement in a smooth
manner.
So instead of using use controller rotation, Yaw, we're going to use our movement component to orient
in the direction of movement.
So let's go to our character movement component and check use controller desired rotation.
We'll set that to true.
And now that we're using the controller desired rotation, we'll rotate to face that controller rotation
and we'll do so in a smooth manner using rotation rate.
If we increase that rotation rate, at least the Z component, which is the yaw component, if we drag
this up to a really high value, then we'll see that Snappiness it's going to really just snap to that
rotation.
But if we lower that value, say 360 was what it was at, we could be a little faster, we could say
400 here.
Then in that case we'll see a smoother rotation.
They'll turn to face us.
And if that's even slower than 400, then we won't even notice that it's being set in periodic intervals.
So I think that looks pretty good.
We could actually lower it.
360 was a pretty good value.
So a couple of variable values that we changed gave us smoother behavior.
For one, we don't want our enemy using controller rotation yaw, but we do want our movement component
using the controller desired rotation.
And those two booleans should be set in C plus plus.
So that's the default values of them.
But the rotation rate is something we can tweak from blueprint.
So here in Writer, why don't we go into our character folder open ora enemy and make sure those properties
are set here in the constructor?
So the first is B use controller rotation and there are yaw pitch and roll.
I'd like to set them all to false.
So we're going to say use controller rotation pitch, set that to false, we're going to use false for
roll and especially the yaw.
We're going to set that to false and then we can get our movement component.
So we're going to use get character movement.
And if we search for comptroller here's that be used comptroller desired rotation.
We're going to set that one to true and next time we compile, those changes will be compiled.
But we've also set that in the blueprint as well.
So that takes care of smoothing out character movement.
So that looks pretty good.
Now, next, we want to avoid having our enemies pick up pickups, but these are all effect actors.
So maybe we do want our enemies to actually be affected by the fire.
So some effect.
Actors should affect enemies, some should not.
And for that reason, we're going to want to check what that other actor is.
Now, recall that we gave our enemy base a tag.
If we search for tags, we have the enemy tag and we can check for that.
We can go into writer.
I'm going to close out of the editor now and we're going to go into our effect actor so I can close
our enemy.
We're done with that.
For now, we're going to go into aura effect actor and we can check before applying an effect to the
target.
We can check that target actor and see if it has the enemy tag.
Now, sometimes we want to actually affect the enemy tag, and for that reason, I'd like a setting
on the effect actor that we can set a boolean of sorts just like destroy on effect removal, which we
never actually used, did we?
So we can actually use that too.
So let's make a be apply effects to enemy.
Or we can say to enemies and it'll be set to false by default and I think be destroy on effect removal
makes less sense than say destroy on effect application.
So I think this should be changed.
I'm going to double click on it and right click go to refactor and rename and instead call this be destroy
on effect application.
Now renaming a property can break existing data in assets.
Adding a core redirect to the configuration file tells Unreal Engine to remap obsolete data while loading
assets so we can go ahead and add the core redirect.
And now it's called Destroy on Effect application.
So now we can check these booleans if we want to check be apply effects to enemies.
We should do that here in our apply effect to target as that's what all these overlap functions are
doing.
But really I'd like to check in on overlap and on end overlap as well because those have to do with
storing active effect handles.
So first of all, here in apply effect to Target, I'm going to make a local const boolean called be
is enemy and set that equal to and we're going to get the target actor and call actor has tag specifying
the name enemy.
So we know that the target actor is an enemy if it has the tag.
So if it is an enemy, so if B is enemy and we're not supposed to apply this effect to enemies, in
other words, and not be apply effects to enemies, then we can return.
So if it is an enemy and we're not supposed to apply effects to enemies, we'll just return.
We're going to take this line here and in fact, we don't need be is enemy.
If we want to compact this into one line, we can take this target.
Actor actor has tag and replace it there.
And we have a single line.
Now we can use this same line in our overlap functions as well.
So we'll go ahead and add this to on overlap and we'll add this to on end overlap.
So basically these functions will all ignore actors that are enemies.
Okay, great.
So now we have this other boolean destroy on effect application.
If that's true, we should destroy as soon as we apply the effect and we can do that in apply effect
to target.
And I think that we should really only destroy our effect actor if our effect is an instant effect.
So if it's an infinite effect, why would we destroy it if the effect is going to linger until possibly
we stop overlapping?
So what I'd like to do is check to see if this is an instant effect.
If it is, then we're going to go ahead and destroy the self.
So let's say if B destroy effect on application An and and we'll also take our effect spec handle dot
data dot get we'll get the def from that have to use dot get there and get the duration policy.
And we'll see if this is equal to E.
Gameplay effect duration instant.
So if it's an instant effect and we're supposed to destroy an effect application, we'll destroy.
So in this case, only if that boolean is set are we going to destroy.
So let's go ahead and test this out with our pickups.
Okay.
I'm going to go ahead and get my actor folder open and go into area and open fire area.
I'm going to leave destroy on effect application off, but I'm going to check apply effects to enemies
now because these are false by default.
That makes it a little easier because I don't want to apply these other effects to enemies, but I do
want to go in and check destroy on effect application.
So I'm going to go into Potion BP Health Potion, and I'm going to check Destroy on Effect application
for that.
I'm also going to do that for mana destroy on effect application.
And I'll do the same for my crystals as well.
So here's my health, Crystal.
Destroy on effect application.
Here's my mana crystal destroy on effect application.
And now we can save all and test these things out.
And they do destroy those crystals.
But I'm remembering now if I go back into Mana Crystal, we're calling destroy actor here in the blueprint.
And that would be why.
So I'm going to remove that from Mana Crystal.
I'm going to remove it from health crystal.
We're going to remove destroy actor from mana potion and from health potion because now apply effect
to target will take care of destroying the actor.
So saving all again let's try that again and make sure that.
Those effect actors ignore the enemies.
Let's see if they take damage and they are taking damage from the fire.
Let's see if they take any of these other pickups.
They don't.
Let's make sure we can still pick those up.
And we can.
And things are looking great and those pickups are still being destroyed when we pick them up.
Actually, it looks like the crystals are not being destroyed.
Let's go to Health Crystal.
And the reason they're not being destroyed actually here is because we're not destroying them, because
we're using a duration gameplay effect class.
So you know what?
I think it's okay to destroy duration based effects as well, and we'll just choose not to destroy infinite
effects.
So because we know whether or not it's infinite, we'll only destroy if be infinite is false.
So I'm going to change this line to say, if not, be infinite, destroy.
And I think that is going to give us the behavior we want.
Okay, so with that change, let's test things out.
And everything looks like it's behaving correctly.
Perfect.
All right.
So that is a great milestone.
Things are working smoothly so far.
And we have I chasing us around.
It's not picking up pickups that it shouldn't pick up, but it is interacting with effect actors that
it should interact with, which is exactly what we want.
Now, while we're on the subject of polishing and before we wrap up this video, I'm noticing one small
little annoying issue, and that's with my health globe.
I'm noticing my ghost globe isn't quite going all the way to where it should go, and I already know
and suspect what that's from.
I think that is from the padding.
So if I go to my Globe Progress Bar and Select Ghost, I'm pretty sure that it's because this has no
padding.
But my progress bar globe itself has padding of ten.
Now, a couple of students also mentioned that if your globe and your background ring image are not
100% perfect and it looks like you have a little bit of an offset, you can make that ring, that background
image, the very, very front.
We can bring it all the way to the front and that way you may not even need any padding at all.
So I'm going to keep that on the front there.
I think that's going to look pretty good.
But I also think I want my progress bar ghost to have the same padding as my progress bar globe, which
means I'm going to need to go up into my update functions where I'm updating my globe padding.
While I'm at it.
I'm going to go ahead and just set my progress bar.
Ghost padding as well.
So I'm going to get that.
I'm going to use slot as overlay slot.
And I'm going to call set padding.
The function version of this, and I'm going to use the same exact padding as for my globe.
Now, if I do that and press play, not only do my rings look a bit better, my globes are behind them.
But as I take damage, let's just make sure that Ghost Globe goes down all the way to where it should
go.
And it looks like it is.
That's looking pretty good.
Yes, much better.
And I can go drink a health potion.
Maybe also a crystal.
That was a man.
A crystal, though, by the way.
Let's get a health crystal.
There it goes.
Looks like it took me all the way up to 100%, but we're clamping.
So if I get some fire, I should start taking damage right away and everything is going to the correct
values.
Perfect.
Okay.
So just a nice little tweak on the progress bar there.
I'm going to save all and things are looking great.
I'll see you in the next video.