Welcome.
Now we know how to apply instant gameplay effects and we also know how to set a duration for gameplay
effects.
And we saw that at the end of that duration period the effect was removed or undone.
Now we can also have effects that execute some sort of change periodically.
But before we get into those, we need to have a bit of a deeper understanding of the difference between
these duration policies and how they affect the attribute.
You see, we know that the attribute has a base value and a current value, and we've already mentioned
that temporary effects affect the current value.
And when those effects are removed, that current value has that effect undone and the current value
goes back down to the base value.
Now we've seen that instant effects seem to be permanent, and that's because instant effects affect
the base value with a permanent change.
So when we apply an instant effect, we're not applying that change to the current value because we
don't plan on undoing it later.
Now this is different than how duration and infinite effects work.
We haven't created any infinite effects yet.
We will, but they work similar to the duration infinite effect in that they cause changes to the current
value which can be undone if and when the effect is removed.
Now duration based effects remove themselves.
We set the duration, say two seconds and after two seconds the effect is removed, which means any
changes to attributes are then undone.
This is why the change is applied to the current value.
Infinite effects behave similarly.
The only difference is they don't remove themselves.
If you want to remove them, you have to do so manually.
Now duration and infinite effect can be converted into periodic effects, which means that they execute
some kind of change to an attribute periodically, every so often as long as that effect is currently
applied.
So periodic gameplay effects are a special flavor of duration and infinite, but the periodic changes
that they execute are treated like instant gameplay effects and that they change the base value permanently.
They're not something that you undo.
If a duration or infinite gameplay effect that's set to be periodic is removed, all of those changes
that occur every period are permanent.
They don't get undone when the effect is removed.
So that's how periodic works and we can convert any duration or infinite gameplay effect into periodic
by simply changing its period to a non-zero value.
And that's what we're going to do to our health.
Crystal Now.
So I'm back here in the editor and I have my crystal heal now.
This is a gameplay effect with its duration policy set to has duration.
And this just means that the effect is applied and then it removes itself after an amount of time and
that's scalable float magnitude, which we set to two seconds.
Now the modifier is applied as soon as this effect is applied.
So we chose the attribute max health.
We chose the operation to be Add and the magnitude to be 100.
So max health will have 100 added to it.
But because this has a duration, that 100 is removed at the end of that duration.
Now we can change this to a periodic gameplay effect by scrolling all the way up to the top and under
period.
We have a period property and it's set to zero.
If this is set to zero, this is a non periodic effect and period doesn't apply.
But if we set this to a non zero non negative value such as say one, then this effect will be applied
every one seconds.
Now execute periodic effect on application is a boolean we can have checked or unchecked.
If it's true, then as soon as we apply the effect then the modifiers will be applied instantly as soon
as the effect is applied.
But if you uncheck this, then we have to wait one period before we get that first application of the
periodic effect.
So nothing would happen for a whole second and then the modifier would be applied.
I'm going to leave it checked.
And because we have a period of one second now, our modifier will be applied as soon as we apply the
effect.
And then again after a second and then again after another second because we.
We have a total duration of two seconds.
Now let's change this attribute from Maxhealth to just health.
And instead of adding 100, I'd like to add, say, ten, and we can just check out how this works.
I'm going to compile press play and enter the show debug Command so we can see that our health is 50
and I'm going to go ahead and pick up our crystal and see what happens.
We see 60, 70, 80 and it stops.
So every second we get ten added to our health.
Pretty nice.
You can adjust these parameters to your heart's content.
We could change the magnitude to one and we can change our period instead of one second.
We can choose 0.1, so a 10th of a second.
In other words, the effect will be applied ten times per second, and each time we'll add one to the
health.
That gives us a bit of a more rapid health increase.
If I keep an eye on the health globe and pick up the crystal, I see that it's growing steadily now.
You might be tempted to really crank this by setting the period to say 0.01, right, 100 times per
second.
And at each period we can increase the health by 0.1 and then we get a much smoother increase.
Right.
Let's take a look at that.
There we go.
That's much smoother, right?
But keep in mind that gameplay effects are predicted and they register these changes with the ability
system each time.
So it's not really just a trivial setting of a variable, but there are potentially other things that
happen as a result of application of gameplay effects.
So while you can apply effects this rapidly, really you're going to want to achieve that smoothness
and potentially other ways.
For example, if I set this to increase, say only ten times per second or once every quarter second,
we can interpolate and show the health changing in a smooth manner with tricks on the widgets rather
than just forcing this effect to have its modifiers applied so rapidly.
So what I'm going to do is set this to 0.1 and set the modifier to one.
I think that's a pretty decent balance.
And that way as we pick up the health crystal, we get ten times per second One health added every single
period and that seems pretty decent.
So now we know how to apply periodic effects by simply changing the period to a non-zero value.
Now notice if I change the duration policy back to instant, I can scroll up and notice period doesn't
have the ability to set the period, so period only becomes an option when you change it to has duration
or infinite.
As soon as you change that, then you can go back up and see the period and notice it remembered my
0.1 seconds.
Now let's go back to execute periodic effect on application again with this checked which it's been
checked the whole time.
I'm going to show debug and we see that our health is 50.
I'm going to pick up the crystal and notice it goes all the way up to 71.
We're applying our effect ten times per second for two whole seconds.
So we're adding one to our health each period and there are ten periods per second.
But we started with 50 and we ended up with 71.
It seems like there's an extra one there, right?
And that's because we applied the modifier on execution.
That's because of the setting here.
Execute periodic effect on application.
That's application of the gameplay effect itself.
Now if we uncheck that, then we'll have to wait a whole 10th of a second before we see that modifier
applied.
So with it unchecked, now I'm going to show debug and pick up the crystal and we see that it goes all
the way up to 70, but not 71.
So that's the difference there with this checkbox.
So it depends on if you want that modifier applied instantly when the gameplay effect is applied or
do you want to wait one full period?
Now periodic inhibition policy has to do with gameplay effects being inhibited.
You see, gas is very versatile and we use gameplay tags to block things or cancel things.
Gameplay effects can be blocked or inhibited based on tags that a specific ability system component
may have.
And we'll learn more about that when we get into gameplay tags very shortly.
But once we get into them, we'll see that the inhibition policy allows us to choose what to do when
in our gameplay effect becomes inhibited.
For now, that doesn't apply to us.
And one last thing before we move on to your quest for the video is notice that we have a stacking type,
and stacking allows us to choose what happens when we have multiple gameplay effects of the same kind
applied at the same time and we'll get into those very shortly as well.
We won't get into them in this video for this video.
It's enough that we know that we can now apply periodic gameplay effects and our health.
Crystal has now a healing over time quality, which is kind of nice, and it'd be nice if we had something
similar for Mana.
And that's going to be your quest for this video.
I'd like you to make a periodic mana pickup similar to our health crystal.
You can use crystals or you can use.
Really any assets you like, but create this periodic mana effect and create the blueprint based on
effect.
Actor.
Make it look different.
Be creative here.
I'm giving you creative freedom and apply the effect on overlap and play test.
So pause the video and make your periodic mana pickup now.
Okay, so I want something similar to the health crystal, and that means I need a gameplay effect that's
going to change my mana, right?
And really, I can use my crystal heal as a bit of a template to base my mana effect on.
So I'm going to make a new blueprint class.
It's going to be based on gameplay effect.
There we go.
And I'll call this ge underscore crystal mana.
Just like crystal heal.
Now, just like crystal heal, I'm going to cheat by looking at it.
We see the period is 0.1, but in crystal mana we see no option to set that.
And that's because by default, gameplay effects come out as instant.
We got to change this.
We're going to change it to has duration and now I can scroll up and change the period.
I'll go ahead and change it to 0.1, just like my health.
Crystal And I'd like to execute periodic effect on application.
Why not?
And we'll scroll down and add ourselves a modifier.
So for the modifiers, I can click plus and expand that and change the attribute.
And this one we're going to choose Mana.
I'm going to choose the modifier Operation Add.
And for the modifier magnitude, I'm going to add, oh, let's say one mana and for the duration right
here under duration magnitude, let's give this a duration of three seconds instead of two.
I think that will be great for Mana.
I'm going to go ahead and save Crystal Mana and now I can make my mana pickup that will be duration
based.
So I'm going to right click and add a blueprint class.
This will be an aura effect Actor.
I'll select that BP underscore and I'll call this Mana crystal.
That aura effect actor is sure putting in a lot of work, isn't it?
Let's get this effect actor and select the route and I'll go ahead and add a mesh.
So we'll get a static mesh.
I'll call this crystal mesh.
And we have a lot of different assets in this project.
We have the health crystal.
We could use that, but there's also some other things.
If you scroll down and kind of took a look, you might see that there's some other static meshes as
well.
What I think I'll do is use this shard debris, which is a bit of a different looking crystal.
I kind of like how this one looks.
I'm going to use this and I'll add a sphere component here.
We'll add a sphere collision, and I think that's going to be just fine.
And all that's left now is to go to the event graph with our sphere selected and get our on component
began overlap event.
And we'll call our blueprint callable function.
Apply effect to target, which requires an effect class, which should remind us that we need to set
that effect.
And this is a duration gameplay effect class.
We're going to set that to our crystal mana and then I'm going to get that duration gameplay effect
class and plug it in and hook up other actor to target actor and hook this up and I'll go ahead and
destroy the actor at the end as well so we can compile that.
And now I have my mana pickup.
I'm going to go ahead and drag one into the world, save all before I test and press play.
And I'm looking at my man a globe here.
I'm going to get that little crystal there.
And there goes my mana for three seconds.
It almost filled it all the way up, which is exciting.
Now, again, it looks a little choppy because we're only doing it once every 10th of a second.
So of course that's not smooth.
Right?
And I'd like to definitely make this look a lot better when applying effects like this.
We'll get to that in time.
Don't worry.
We can also pick up our other pickups, these potions, which just give us instant changes to our attributes.
So they're a little bit different.
But now we know how to do duration based, which is exciting.
So excellent job.
And we're going to continue with our study of gameplay effects in the videos to come.
I'll see you soon.