Welcome.
In this video, we're going to make an infinite.
Gameplay effect, which means our effect actor should have an infinite gameplay effect.
To subclass of.
So we're going to go ahead and add one.
I just copied duration gameplay effect.
Class and I'm going to name this one infinite gameplay effect class.
And with that I'm going to hit.
Debug, compile and launch.
And here in the editor, I'd like to make a new gameplay effect.
I'm going to go to Blueprints Actor Potion and it's time, I think, to organize these a bit.
I'd like to have a folder for the health and mana crystals.
So here in Actor, I'm going to make a new folder called Crystal.
And from Potion I'm going to move the health crystal, the mana crystal and crystal heal and Crystal
Mana.
With all of these selected, I just held control and left clicked on them.
I'm going to move them over to the crystal folder, select move here and that way our potions are here,
our crystals are here and here in Actor.
I'm going to have a new type, so I'm going to create a new folder.
And for this one I'm going to call it areas.
Or just area rather, and you'll see why.
I'd like to make something that spans across an area.
So I'm going to right click and make a new blueprint class.
I'm going to make an aura effect actor.
And for this I'm going to call this BP underscore fire area.
And for fire area, I'm going to add a box component.
So I'm going to search for box, get a box collision there.
And in addition to this, I'd like to have some fire.
So I'm going to add a Niagara particle system component and call this fire effect and fire effect gets
a Niagara system asset.
I'm going to choose in fire.
So here we have a fire Niagara system and a box that will occupy an area.
Now, this is kind of cool.
If I drag one of these out into the world, my BP fire area, we see that it has fire and I'm going
to go ahead and move it a little closer to my player start.
So we have a fire area here.
And for the fire area, I'd like to apply an infinite gameplay effect when the character is overlapping
with it and an infinite gameplay effect is never removed, at least until you remove it manually.
So that's kind of what I want to do for the fire.
So in order to remove an infinite effect, that's going to require some thought.
But for now I'd like to just apply the infinite effect and see what happens.
So here in my area folder, I have my fire area.
I'm going to right click and make a new blueprint class based on gameplay effect.
And call this GE underscore fire area and open fire area and this will be an infinite gameplay effect.
So duration policy will be infinite and we now need to decide what to do when we apply this effect.
Well, I'd like this to be periodic, so I'm going to go up to the period and I'll give this a period
of one second.
So every second will be applying any modifiers.
And speaking of modifiers, we'll add one and the modifier is going to affect the health attribute.
It's going to use an additive operator.
And what are we going to add?
We're going to add a negative value so we can subtract from the health.
I'm going to subtract five from the health every second.
So we have the fire area.
Let's compile and save.
And here in BP fire area, I'm going to select BP Fire Area Self.
Here's my infinite gameplay effect class.
I'm going to choose GE Fire area and now we need to apply it.
So here in the blueprint event graph, I'm going to get my box right click on component, Begin Overlap
and I'm going to simply apply my effect.
So apply effect to Target.
I'm going to hook that up.
Plugging in the other actor for Target actor and I'm going to get my infinite gameplay effect class
and hook that in and I'm not going to destroy the actor.
So on overlap we apply an infinite gameplay effect.
So what happens?
Let's go and find out if we overlap with this area.
I'm going to press play and I'm going to overlap with the fire and there's my health going down every
second It's going down.
Now here's the problem.
If I leave the area, well, the effect is still applied and if I show debug, we see health going down
into the negatives, it's never going to stop.
So if we do apply an infinite gameplay effect, it's up to us to remove that effect.
And so in this video we're going to learn how we can do that and we'll handle this on the C plus plus
side of things as this is one of those things that I feel makes more sense to handle in C plus plus.
So what I'm going to do is I'm going to close the editor, save all, and let's think about how we're
going to handle these gameplay effects in our effect.
Actor Depending on which ones are set here, now we need to think about how we'd like to handle applying
our different types of effects because we have an instant effect.
We have a duration effect and we have an infinite gameplay effect.
We have to decide how the aura effect actor is going to apply and or remove these effects.
And I'd like to be able to change how the actor applies the effects from the blueprint.
I want this to be nice and flexible and configurable.
So what I'd like to create is a policy, an enum for the effect application and the effect removal.
So we'll have an effect application policy, essentially a setting that we can set that determines whether
we apply any of these effects on overlap or on end overlap and so on.
So let's create an enum up here at the top.
We're going to make a scoped enum.
We're going to say Enum class E, and this is going to be our Effect application policy.
So we're going to say E effect application policy.
In other words, how are we going to apply the effect?
And it's going to be a U enum.
We're going to make it blueprint type and the constants for our policy will be apply effect or just
apply on overlap.
We can have apply on end overlap.
We can have do not apply.
And if we create a variable of this type for each of these, we can set it in the blueprint.
For example, we can have an effect application policy for the instant effect.
So we can call this instant effect application policy.
And we can make this edit anywhere.
So I'm going to give it a new property, make it edit anywhere and it can be blueprint read only category
applied effects.
So really I'll just copy this property from up there.
So we have one for the instant effect.
We can have one for the duration effect as well.
So I'll copy and paste it here and have a duration effect application policy.
And then we can also have a infinite effect application policy.
Now, in addition to the application policy, I'd like to have a removal policy as well.
So I'm going to copy this enum and paste it here.
And this will be effect removal policy.
So we're going to replace application with removal.
And we'll delete those constants.
And what are the removal policies that we want here?
Well, we can have remove on and overlap and we can also have do not remove.
Now, a removal policy really only applies to an infinite gameplay effect because a duration based gameplay
effect is going to remove itself.
It handles that on its own, but for an infinite effect.
We're going to want to either remove it when we end overlap or simply never remove it.
So we'll only have an effect removal policy for the infinite gameplay effect.
So we'll go ahead and add that and it's going to be infinite effect removal policy.
And it gets an edit anywhere.
Blueprint read only category Applied effects.
So now we have these application and removal policies and we can check these when we apply our effects.
So now we're going to need a different way to handle applying our effects.
We're going to want to apply the instant effect by checking our instant effect policy.
And if that policy is do not apply, then we're not going to apply that effect.
And in fact, I think that do not apply is a pretty good default value for each of these.
So I'm going to set instant effect application policy to effect application policy do not apply and
I'm going to set all of them to this.
So duration effect application policy do not apply and infinite also do not apply.
And for the effect removal policy for the infinite effect, I'm going to give this one a default value
as well.
Now we could have it set to do not remove.
I'm going to have it set to remove on end overlap by default.
And now that we have these enums, I think we can have a pair of functions for when we begin and end
overlap that we can call from the blueprint that can just handle these things.
And really all this function needs is to receive a target actor.
I don't think we really need to pass in the effect.
We just need to have those effects set.
And this actor can access its own effects.
And before I make these two functions, I'm going to add a Boolean so that we can destroy our actor
after the effect has been removed if we want to.
So let's make a bool first called be Destroy on effect removal.
We'll set it to false by default and we'll make it edit anywhere Blueprint read only category applied
effects like so.
And now we can add those functions that we want.
So I'm going to make two functions, one for overlapping and one for end overlapping.
And we'll just call these from the blueprint when something overlaps with whatever volume that we decide
to add to our blueprint.
So this will be a void function and we're going to call this simply on overlap.
And this is only going to take an actor and we'll call it target actor.
And we'll also have an on end overlap that takes an a actor called Target Actor.
And we can just call these from Blueprint.
So I'm going to make them blueprint callable, give them the new function with Blueprint callable,
and I'll go ahead and generate the definitions for these.
There's on overlap.
Here is on and overlap and we'll decide which effects to apply and when.
Based on their application policies.
And we're going to do that in the next video.
We'll continue this then.
So great job and I'll see you in the next video.