Welcome back.
So we have the ability to fade things out.
And that's because we made a fade actor.
If we call fade out and fade in, we'll see that we fade out and fade in, and that's great.
But now we need to know when we should fade out, right?
So we're going to handle that in this video.
Now, one thing I'd like to do is just really quick make sure that my fireballs will explode on our
fade actor and that our mouse click is not going to hit our fade.
Actor So we're going to take our mesh and we're going to make sure to set its collision presets.
So we're going to change it to custom.
It's going to be blocking the projectile and ignoring visibility and camera.
And that way if we click on our Fade Actor, we'll just go behind it or go up to it, right?
But if we launch a fireball, it'll blast it.
Okay, so we want our fade actor to fade out when we're behind it.
Essentially, when it's blocking our view of aura, we don't want to see it when it's in the way.
And by the way, I think I'm actually setting it to block visibility when it fades back in.
So that's fine.
But we want a way to call these events in our fade actor fade out and fade in.
And I want to do that from our character because it's our character that's going to go behind it.
Now, I don't want my character to be dependent on the fade actor, so a good way to avoid that dependency
is to make an interface.
So I'm going to actually browse to my fade actor.
And right next to it, I'm going to make a blueprint interface.
So we'll go to Blueprint, Choose Blueprint Interface, and we're going to call this B, I underscore
fade for a fade interface.
We can even call it fade interface if we like and fade interface will have two functions fade out and
one more.
Fade in.
So all we do is just add two functions here and that's it.
And we need our fade actor to implement it.
So we do that by going to class settings under interfaces and implemented interfaces.
We have a dropdown.
Here's by fade interface.
Now that we implement it, I'm going to hit compile and now we see found more than one function with
the same node because we have these custom events fade out and fade in.
We're going to delete those because now we're going to have our own fade out and fade in that we're
inheriting from the fade interface.
So we're going to right click type fade out and we're going to get our event fade out.
That's our interface and we're going to right click, get Fade In and there's our event fade in.
We're going to put that into the reverse, right?
And now we have these interface functions and we need to call these when something is blocking our view
of aura.
So for that reason, I'm going to go ahead and close everything else except for my fade actor and I'm
going to open Aura.
So we're going to go to blueprints.
Character or a BP or a character.
And we're going to add something here.
So I'd like a blocking volume, something right here between the camera and aura.
And we can use this to know when we should fade in and out.
So I'm going to have this attached to my spring arm, and that way it'll be oriented correctly.
So with my spring arm selected, I'm going to search for box, get a box collision, and here's my box
collision and I'm going to drag it down a bit.
So it's kind of in between about like this and I can change the box extent.
So here is the length of it.
I'm going to make it a bit longer.
Turning off, snapping so I can move it around.
And I'm going to go to perspective and front because I want this box to be less wide than my capsule.
That way, if I'm right up against a wall, this box won't be fading that wall out.
But as soon as I go behind the wall, that's when I want to fade out.
So it's going to be slightly less wide than my capsule.
Going back to perspective mode.
And if I'm looking at my character from the camera's point of view, as soon as something obstructs
the character from the top or the bottom, that's when I want to fade it out.
So of course this will probably take a little bit of tweaking, but I'm going to make my geometry look
about like that.
And now I have something that I can use to fade things out.
So I'm going to go to my event graph.
And down here, I'm going to move unused nodes out of the way.
And I'm going to take my box right click and use on component began overlap.
And on overlap, I want to check the other actor to see if it implements the interface that fade interface.
So I'm going to say implements.
And choose does implement interface searching for by fade interface.
And if we do, we'll have a branch.
If we do get that interface, then we're going to right click and call Fade out.
And we'll just fade out that actor.
So we're going to have to bring that other actor straight into that fade out function call.
Mike.
So.
Now, what does our famed actor Mash have as its object type, its world dynamic?
Really?
This could be world static.
We're going to change it to that.
And here in Aura Character, we're going to take our box and ignore everything except for world static.
So we're going to change it to custom ignore all and we're going to overlap with world static and make
sure we're generating overlap events which we are.
The box should be query only and the box itself can be world dynamic as it will be moving around with
aura and the fade actor is world static.
It is set to generate overlap events and it blocks all but visibility and camera, so that'll work.
So that's for begin overlap.
But what about end overlap?
So we're going to use on component end overlap with our box selected and we're going to copy does implement
interface using the other actor.
We're going to have a branch for that.
And if it does implement the interface, we're going to call fade in.
So fade in and then we'll reverse that timeline.
And of course, we have to take that other actor.
And hook it on in.
Like so.
Okay.
So the last thing to do is test out how this all works and to make things easier, I'm going to take
this fade actor and blow it up to a bigger size and press play.
And we can run behind it.
There it goes.
It fades out, comes back in.
And I think I don't really want to block visibility, right, because now I can't really go behind it.
So what I'm going to do is actually go into our fade finished function and remove this function call
to set collision response to channel as we should just ignore visibility.
So we're going to go ahead and just leave it at ignore and remove those function calls.
Pressing play.
Now we can move behind it and it fades out.
Great.
Okay, so this is looking pretty good.
One issue that I don't like is the shadows look a little weird.
They can kind of flicker a bit so shadows don't really play nice with this whole fade out mechanic when
we're using a masked material.
So for that reason, I'd like all my fade actors to not cast shadows.
So I'm going to take my mesh search for cast and uncheck cast shadow.
And now this is going to look a lot better when it fades out and it's going to look like it doesn't
exist.
And we can always tweak this timeline.
I kind of like a shorter fade out, like 0.4 seconds.
So I'm going to take my second key and set its time to 0.4 and set my length to 0.4 for my timeline.
Not four, but 0.4.
And see how this looks with a faster fade out.
I like that better.
And now we can make all of our other actors in our world fade actors.
So instead of using a regular SM tile, three by three by nine, I'm going to right click and select
edit it, and notice that this one has two materials.
So we're going to have to make those fade materials and material instances for both of these.
So I'm going to browse to tile set one right, click on it, duplicate it, call this tile set one underscore
F, I'm going to open it up and we need that material parameter I can hold s and left click to get a
material parameter and call it fade.
And we need to run this.
I'm going to set its default value to one and we need to run this through a dither temporal AA and hook
that in.
But we have to change this material type to masked in order to get that opacity mask.
Now we can apply that and we can go ahead and make ourselves a material instance from it.
And now that we have that, we can use those in a new fade actor.
But before we do that, I'm going to do the same thing for the second material, so I'll browse to it.
Go ahead and duplicate it.
Call this tile set two Underscore f.
Open it up.
And I'm going to take these two nodes from my tile set, one F, copy them over here, change this material
to masked and hook that into opacity mask and apply save and we can make this into a material instance.
So now that we've done those steps, we can make a new fade actor and the fade actor is what I'm going
to use as our base class for all fade actors.
We're going to create a child class based on this so we can browse to it and we can right click on it
and create a child blueprint class.
And I can prefix our fade actors with f A So look at that.
We're creating our own custom prefixes.
How fancy.
And I'm going to use the same naming conventions as our static meshes.
I'm just replacing them with f A So we'll have a tile three by three by two.
That's now a fade actor.
So we're going to say SM tile underscore 3X3X2, and that way it'll be the same as this one.
So I'm going to open up my new fade actor.
I'm going to close my old fade actor for now, and with my new fade actor, I need to change some things.
I'm going to go to the mesh and change it to this mesh that I want to use so I can browse to this one.
Make sure it's selected in the Outliner.
Go back to my new fade actor, hit the left arrow.
So now we're using this mesh.
Which is using these two materials and we need to go down into original materials or actually our fade
material instances actually.
And I need to hit the trashcan and instead use the two material instances that we created.
Now one of them is Tileset one F, and these have to be in order.
So Tileset one F first.
As that's the first material here, so I'm going to add that to the array.
So tile set one F, we have to use the instance.
So making sure the instance is selected, add that to the array.
And now the second one that's tile set to F, but the instance.
So I need to browse to it and select the instance and add that to the array.
So we have those two.
Okay.
So now that we have our fade material instances set, we can bring in one of these.
I'm going to take the actual static mesh and delete it and bring in our new tile.
I'm going to browse to it and bring it in.
Put it in place and delete the others and replace them with the new one.
And of course we can flip it around if we don't want to have these all look the same.
So I'm going to go ahead and duplicate them, flip them around a bit.
And make sure these are all paid actors.
So flipping them around.
And replacing old ones.
Like so.
Okay, so we have these fade actors and I'd like to put all my fade actors into the same folder.
So I'm going to select my fade actors right click move to create new folder, and I'm just going to
click the folder, click it again and rename it to Fade actors.
So now I'll have fade actors and they're different than my dungeon meshes.
Now that I have made actors for these, I can test this out.
Saving all.
First.
I can run beneath here.
And they fade out.
Look at that.
How cool is that?
And you can also just change the size of that box whenever you want to.
Excellent.
Really nice.
This is such a good touch.
Now, of course, these aren't fade actors, right?
So we can easily change that.
This one is three by three, three by three by two.
So I can delete that and just replace it with one of my fade actors.
And then we can make a fade actor for the stairs.
So I'd like you to do this on your own.
Go ahead and make a fade actor for the stairs.
It's got multiple materials.
If you right click and edit it, you'll see that it has four.
So pause the video here, make a fade actor for the stairs and then come back and we'll do it together.
Okay, so we need an A stairs, right?
So I'm going to go browse to my fade actor folder.
Right click on BP Fade Actor, Create a child blueprint class.
Call this FA underscore stairs.
Open that up and we're going to change the mesh.
So we need some stairs.
Browse to it.
Change the mesh.
That's step one.
And we also need dynamic materials for all four of these.
So we'll start with the rail.
We'll browse to it.
We'll duplicate it.
We'll call this rail underscore F.
Change this to a masked material.
Let's see if I still have these nodes copied and I still do, which is amazing.
Stick those into opacity mask and apply and just make a material instance out of it and we're done for
that one.
So that's rail.
Now we have the column, so we'll do the same thing, duplicate, make the fade version.
Change it to masked.
Hook up these nodes to opacity mask.
Apply.
Make an instance.
There's two now for the pillars.
Duplicating it.
Renaming.
Changing to masked.
Adding our nodes.
Apply.
Create a material instance.
And then finally, our fourth material, the steps.
We're going to duplicate.
Rename to underscore f.
Change it to masked.
Paste in those nodes for the opacity mask.
Create a material instance and I'm going to click Save All.
And save all that work.
So now I have material instances that I need to set in the order of rail columns, rims, pillars and
steps.
So here in my fade actor, I can go down to my fade material instances and add four elements.
And we have again, order matters here.
So we need the rail first.
So rail inst.
First.
Next, we need columns, rims.
We'll use the insert.
Next.
We need our pillars.
So we'll choose that, set that.
And finally, we need our stairs.
So setting that material instance as well.
And now we have a stairs fade actor So kind of a lot of steps.
It's kind of a pain because of what we're using for our materials.
But once you got the process down, it's pretty easy to get a new fade actor and we can take this stairs.
Actor I'm actually going to copy its transform.
Its location.
I'm going to copy that and then delete.
And then bring in my new fade actor for stairs.
I'm going to browse to it, bring it in, and then right click on its location and paste so it's right
there in place.
I'm going to save all.
And now let's see if it fades out.
And it does.
And of course, we have one more thing, the rail.
Right.
So let's just make a corner railing fade actor really quick.
I'm going to time lapse this one.
Okay, so I've made a fade actor for this one.
So I'm going to take this actor and copy its location.
It has a rotation of zero.
I can delete that and I can bring in my new fade actor and right click on location and paste and it's
there and we can test it out.
So pressing play.
Let's go behind some things and they fade out.
They fade in and out.
So I'd like them to fade back in as soon as I'm just about above it so I can just really quickly adjust
my characters box so it doesn't have to be quite so low.
I'm going to bring it up a little bit.
Turning off.
Snapping.
And let's see if we can zero in on the right dimensions.
This doesn't have to be that large.
There we go.
And as soon as I get just obstructed, it fades out.
And as soon as I'm no longer obstructed, it fades back in.
So a smaller box can give you a sort of tighter window for fading in and out.
So right here is the rail.
And as soon as it obstructs me, then it fades out.
And as soon as it's no longer obstructing, it fades back in.
That's the behavior I want.
Perfect.
Excellent.
This is a really nice effect.
So it's a really good feature to have for a top down game.
And now we have it.
Awesome.
This isn't a fade actor, is it?
But it could easily be one.
We can just take one of these.
And bring it on over.
Now, one last thing I'd like is to be able to choose whether or not my fade actor blocks visibility
as I don't want these pillars to block visibility.
I want to be able to run around them.
But I do want to be able to click on the staircase and we can't really run to it.
I mean, we can, but it's acting like we're clicking behind it.
So I'd like to have like a boolean that we can set that allows us to block visibility at least when
visible.
So back to our parent blueprint in Actor.
Fade.
Actor.
Fade Actor.
I'm going to go back into fade finished and replace that call that we had where we took our mesh and
we called set collision response to channel choosing our visibility channel.
So if we're finishing our fade and our fade is greater than or equal to one, that means we just faded
back in.
So I'd like to block visibility in that case.
And if we're fading out, if our fade amount is zero, then we're going to ignore visibility.
But I only want to do this if we have a boolean set.
So otherwise we don't want to ever block it.
So what we can do is we can have a branch here and promote the boolean to a variable called block visibility
and we'll block visibility.
If that's true, and we don't need to check it when we're setting it to not block visibility.
But if you don't want to make that unnecessary function call, you could check it.
So we could just have it there.
So as long as my stairs themselves have their default for their mesh set to block visibility, we're
good.
And I'd like this piece of geometry here to also block visibility.
So we're going to go to this one.
I'm going to go ahead and browse to the asset.
Open it up.
We're going to set block visibility to true for this and make sure the mesh is set to block visibility
by default.
And it is.
Okay, so if we click on the stairs, we go on to the stairs.
If we click up here, we go up there.
And we can still fade these things out.
And it looks like I don't want these to block visibility, so I'm going to select them.
Make sure that their meshes don't block visibility.
And I want my boolean here to be exposed.
And I'm going to uncheck that and I'll just duplicate this.
So these other.
Blocks also don't block visibility.
There we go.
Okay.
And these two also should not block visibility, so they won't.
And they still block the fireball, of course.
Perfect.
All right, So things are looking good.
I don't feel like I need this extra aura mesh in there.
And with that, we're ready to continue.
I'll see you in the next video.