Welcome back.
Now, we'd like a checkpoint.
Now, by a checkpoint, I mean something in the world that once we reach it, we'll save our progress.
Something that looks kind of like this.
So I'd like to make a checkpoint class, but I'd like this to be based on the player start class.
And not just a regular actor.
Why?
Because I like it to have a player start tag.
And I'd like to be able to spawn in at one of these checkpoints, so I'd like it to behave like a player.
Start that our choose player start function can use.
So for that reason, we're going to make a new checkpoint class based on the player start class.
Let's go ahead and go to C plus plus classes Aura Public.
Now we could put this in actor, but really it's going to be its own thing.
It's going to be a checkpoint.
So I'm going to make a new C plus plus class.
Go to all classes and look for player start and choose player Start.
And this can go into our checkpoint folder and we're going to call this simply checkpoint.
Let's go ahead and create the class.
And we'll close down the editor and find our checkpoint class.
Now, we do have a lot of tabs open.
At least I do.
So I think for now I'm going to go ahead and just close all tabs and go straight to my checkpoint.
And that's going to be in public checkpoint.
Here's the header file.
Here's the cpp file.
And we have ourselves a checkpoint based on a player start.
Okay, great.
Now our checkpoint is going to need a few things.
I'm going to give it a public section and create the constructor.
And go ahead and generate the definition for the constructor.
We don't need the tick.
So we can take primary actor tick dot b can ever tick equals false.
We can set that right away.
And I like a couple of components here.
For one I'd like a static mesh.
Now let's take a look at the player start class.
Let's go to it.
And you may have noticed that player starts have a capsule.
Now player starts are based on a navigation object base.
Now we can go deeper and go to that class.
And notice that we have a capsule component along with a good sprite and a bad sprite.
And notice the capsule is not editable.
It's not visible anywhere.
It's just there.
And the good sprite and bad sprite, those are billboard components for when our player start is in
a bad location or a good location.
Now if we go into the cpp file here, we'll see that the root component is the capsule.
So we're going to have to live with the capsule being the root just like it is in the character class.
No worries.
We'll just keep that in mind so we can close those.
And for the checkpoint I'd like a couple of variables.
I'm going to make a private section and make a t object pointer of type.
Use static mesh component I'm going to call this checkpoint mesh.
I'm going to give it a uproperty.
Make it visible anywhere.
And in addition to checkpoint mesh, I'd also like an overlap volume that we can overlap with to reach
the checkpoint.
So I'm going to make another T object pointer.
This will be a use for your component.
I'd like it to be a sphere.
I'm going to forward declare that type and call this sphere.
And we're going to make this visible anywhere as well.
And I'd like to overlap with the sphere.
So I'm going to need an on sphere overlap function.
And where do we have an on overlap function that we can steal from.
Let's go to aura projectile.
That one has an on sphere overlap.
We can copy that signature.
Let's make our life easy and use that.
This will be protected.
We have on sphere overlap.
Let's go ahead and generate the definition for that.
And with that, I think we have a good start.
So I'm going to bind my on sphere overlap to the on component, begin overlap on the sphere and begin
play.
Which means I need to override begin play virtual void begin play override.
I'm going to go ahead and define that as well.
So now we have a few things we need to do.
First, I'm going to construct my new objects I don't need or a projectile anymore.
Unless of course I want to copy create default subobject here.
Actually, that sounds like a pretty good idea.
Let's do that right there.
And I'll include use sphere component and I'm going to attach it to the root.
Set up attachment to git root component.
Now let's look at our projectile settings for the sphere we're setting.
It's collision enabled to query only setting it to ignore all except for world dynamic and world Static
and overlapping the pawn.
We can just copy all this, actually.
Why type out boilerplate?
Now we don't actually want this to be set to the collision object type IC projectile.
So I'm going to go ahead and remove that line.
But I do want it to be query only.
I do want to ignore all and I only want to overlap with the pawn.
So I actually don't even need these two lines.
That is perfectly fine.
Now for constructing our static mesh.
Really, I can copy this line with create default subobject in it and paste it and just replace a couple
of things.
This is going to be the checkpoint mesh.
It's going to be a U static mesh component.
We'll call this checkpoint mesh.
I'm going to set its attachment and its collision enabled.
So I'm going to copy those from above.
So checkpoint set up attachment will attach to the root component.
We'll set collision enabled.
And I'd like to use query and physics for the mesh.
And I wanted to block all.
So I'm going to set collision response to all channels.
So I'll copy that line replace sphere with checkpoint mesh.
And I'm going to use ACR block.
I'd like to block all.
And there's my checkpoint mesh okay.
So I also want to bind to a delegate and begin play.
Or a projectile has that covered as well.
We're going to go ahead and just copy that line.
And we're going to paste it here.
The only difference is we're not in aura projectile.
We're in a checkpoint and we have that covered as well.
Okay.
So we have a checkpoint.
We have an on sphere overlap.
And we do want to handle saving the game and all that great stuff.
But we should also handle what happens visually.
We should have some kind of visual change to know that we've reached a checkpoint.
Well, this particular static mesh has a material with some parameters that can be changed to make it
glow.
So let's compile and launch and go into the editor, and I'll show you what I mean.
Okay, so I'm getting a compiler error.
No appropriate default constructor available.
That means we can't actually have a default constructor like this.
We have to have a specific kind of constructor.
Let's go and look at player start to see what that looks like.
So go to Declaration of Usages.
And here's the player start constructor.
We have to have.
It needs to take an object initializer.
So we can copy this const reference to one and come back to checkpoint and paste that in and come back
to our definition for it and paste that in.
But that's not the only thing we have to do.
We also should go to player start CP and take a look at what's happening here.
Notice there's this super called with object initializer.
We're going to have to do that in our checkpoint as well.
So we're going to call super with object initializer.
But notice that it looks like I have a typo here.
This should be object initializer with an r at the end.
So that's going to fix that.
If we put that ah there.
And now we have the correct type of constructor.
And we can go ahead and compile and launch from here.
All right, so I wanted to show you something special with our checkpoint.
If we go to assets dungeon checkpoint and open static mesh checkpoint, notice that it's material is
a material instance.
And if we browse to it, here's the material instance.
And I'd like to use our preview mesh SM checkpoint.
I'm going to browse to the checkpoint and come back to our material instance and set that as the preview
mesh so we can see what it looks like.
And notice we have a glow parameter.
And if we click and drag it to the right, our runes glow as well as part of the crystal so we can make
this glow.
And that's a good indicator that we've reached the checkpoint.
So I'd like to use that.
I'd like to create a dynamic material instance that we can ramp up with some kind of a timeline once
we overlap with our checkpoint.
And so for that reason, I'd like to add another variable onto our checkpoint.
C plus plus class I'd like a function actually to create a dynamic material instance that we can then
set properties for with a timeline.
So really I just want a blueprint implementable event.
So I'm going to make a void function called checkpoint reached.
And checkpoint reached can take a you material instance dynamic.
By pointer.
And we'll call this dynamic material instance.
And I'm going to make this a blueprint implementable event so it gets you function blueprint implementable
event.
And I want to call this as soon as we've reached our checkpoint.
So I'm going to have a function that will call this after creating a dynamic material instance.
So I'm going to make a function that's void call handle glow effects.
With no input parameters.
So I'm going to go ahead and generate handle glow effects.
And in Handle glow effects, I'm going to create a dynamic material instance and call my blueprint implementable
event checkpoint reached.
So in Handle Glow Effects.
At this point I know my on sphere overlap will have been called as I'm going to call this from on sphere
overlap.
So first I'm going to take my sphere and set collision enabled on it to no collision.
So e collision enabled no collision.
And then I'm going to create a dynamic material instance.
I'm going to say you material instance dynamic.
That's a pointer.
This is going to be called dynamic material Instance.
And I'm going to create one with you.
Material instance dynamic double colon create.
This is a static function that can create a new material instance.
And it takes a material interface.
Well that's great because our checkpoint is using a material instance as its material.
So if we take our checkpoint mesh and call get material which requires an index and it's our first index
so we can pass in zero, then we can create this dynamic material instance.
Now the outer can be this.
So this actor is going to own it.
And now that we have a dynamic material instance we can set our checkpoint mesh.
Material with set material.
Passing in first our index zero and our dynamic material instance.
Dynamic material instance.
Now, once we've set our checkpoint mesh, then I'd like to call my blueprint implementable event checkpoint
reached and pass in that dynamic material instance.
So I'm going to call checkpoint reached.
Passing in dynamic material instance.
And we can handle the rest in blueprint.
And as soon as on sphere overlap happens, I'd like to call handle glow effects.
And we can perform some basic checks, like we can check other actor and make sure it has the player
tag and so on.
So I'm going to say if other actor actor has tag.
Checking for f name player for instance.
And that needs.
Parentheses there.
Then we can call handle glow effects and after handle glow effects.
We've disabled collision on our sphere, so we can't do this more than once.
So all we need to do now is implement our blueprint implementable event checkpoint reached in the editor.
So I'm going to go ahead and we'll close out of the editor.
And we'll just relaunch and create a quick timeline that we can use to ramp up our glow effect.
So back in the editor.
Now that we have our checkpoint class, we can make a checkpoint.
Let's go into blueprints and we'll just go ahead and make a new folder called checkpoint.
And here in checkpoint we'll make a new blueprint based on checkpoint.
We'll go ahead and select that class.
We'll call this BP checkpoint.
So here's our player start.
Now because it's a player start it has a capsule.
If we select it we can see it.
We also have our sphere component which we can increase the radius of.
And in addition to all this we also have a checkpoint mesh which we can set.
And I'm going to set it to checkpoint.
So static mesh checkpoint.
Now here's the thing.
If this is a player start and we load in at this player start, well we're going to want to make sure
we don't load in like right here in the center of it.
Right.
So what we can do is make our player start center offset from our mesh.
Really it's our mesh that'll be offset from the center.
We could take our checkpoint mesh and we can move it on back right here.
So it'll be on the ground, but we'll spawn right in front of it, and we'll just make sure that we
position this such that wherever we want to spawn, that'll be where we put the center of this.
And actually, if we want to spawn in facing this particular mesh, we can actually put the mesh on
this side of it, because we have a nice arrow component that shows which direction we'll face if we
spawn in.
So we can put it right there.
Now.
Our sphere, though, should be right around where our mesh is, so it might be a good idea for the
sphere to be attached to the mesh itself.
For now, I'm just going to move it over.
But we could make sure next time we compile that that sphere is connected to the mesh.
I'd like that.
So I'm going to go ahead and move these lines down below the checkpoint mesh lines and make sure that
the sphere is attached to the checkpoint mesh.
So we'll do that next time we compile.
That will be fixed.
But here we have our checkpoint.
And if we spawn in at this checkpoint, let's take a look at our capsule.
Here's where our capsule would be.
So if we want our mesh to be on the ground, it should be right there at the bottom of the capsule.
So I'm going to take my perspective and go to right so I can see what I'm doing.
And I'm just going to move my mesh down to just about this line here.
So right about there.
But I'm going to select my capsule and make sure whoops, I overshot.
I think it's here.
And I can zoom in a bit and I can even just make sure.
By bringing this over and selecting the capsule that I'm not too low.
So that looks pretty good.
We can go a little bit into the ground.
Like that, and then I can move this over.
And I can also take my sphere and move it down.
To about there, and I can even make my sphere radius.
The same radius as the mesh.
So about there.
And that looks good.
I'll go back to perspective.
And now if I bring one of these in.
I can compile, I can save.
I'll put one of these in here, but this is actually our load menu.
Let's go into our dungeon and we'll go back here.
This is the back of the place.
See, there's the front.
Here's the back.
I'm going to just remove this player, start and bring in a checkpoint.
So blueprints checkpoint, BP checkpoint.
And here it is.
And we see what it looks like.
I can hit end and it'll go straight to the floor like this.
Okay, so now we just need to implement that glow effect with our blueprint implementable event which
we called Checkpoint reached.
So we have our checkpoint reached event.
We can implement that in our blueprint.
So we can go to the event graph.
Right click Get Checkpoint reached.
And we have our dynamic material instance.
All we need is to make a timeline.
And we'll call this glow timeline.
We'll open it up, add a float track, call this glow track and add two points to it.
Add one key.
The first one will be at time zero and have a value of zero.
And then how long do we want this to go?
Perhaps one second, and at one second we'll put it at one.
I'm going to take both of my key points.
Make this an auto curve so it's smooth and set the length to one.
And in the event graph we're going to play the curve and take our glow track and set a dynamic material
instance parameter.
So let's reroute this around and set scalar parameter value.
This will be on update the value it will be.
We'll just try the glow track.
And what is that parameter?
It's called glow.
And if I bring this up to one, what does it look like?
Okay.
It's glowy.
We could bring it up a little bit more, maybe even 20, 30, 40.
So for that reason I'm going to scale this by a number.
We're going to multiply.
We're going to promote that to a variable called glow factor.
Set glow factor to a default of say, 20.
And hook that in to value, and the parameter is called glow.
Okay.
So with that, we can try to overlap with this.
And since we're testing, I'm going to bring it in close.
So it's easier to find and reach.
Doesn't take too long to go over there.
I'm going to save all and just test out this glow effect.
And there it is.
So now we can see when we've reached it and it stays on.
We don't get this triggered multiple times.
We only get it the first time and it works.
And the cool thing is this is a player start so we can use it and we can save the player start name
that tag.
If we want to save our progress at this particular player, start and we're going to handle doing that
next.
Great job.
I'll see you soon.