All right, welcome back everyone in this video Our goal is to create a lens on and a lens off function inside of our BP player. Now you may have noticed when we activated our white magic Lens of Truth skill in some of the previous videos there, what are some of the things that we saw change? Well, when we turned it on, we saw the meter appear. We saw the materials for our secret wall and our secret platform change. We we even made our secret platform show and hide and even made it so that the collision toggled on and off. So we're going to be creating a couple of functions here to turn on and off those various effects.
So with that all out of the way come under your content Metroidvania blueprints characters folder, double click on your BP player because this is where we're going to be creating our functions inside of our People are over in the My Blueprint panel, find your function section function section and let's create a new function. And I will call this lens FX underscore on. Okay, a lot of things we're going to do when we call this function, the first thing I want to do is down in our variable section come under your white magic Lens of Truth, we want to grab our B is using lens Boolean variable that we created many moons ago. We're going to drag it into our graph, drop it, we're going to set this and here we are going to say that yes, we are using the Lens of Truth. Then we're going to drag off of this and we're going to play a sound.
Play a sound 2d and the one that I want to play here is is clicking this drop down. It's called eg from player Q. And I'm going to click this little drop down arrow here to bring on some of my advanced options because I want to up the volume multiplier here to be three. K, then after this, I want to grab my W, my widget w magic timer. Let's drag and drop this component into our graph. And then we want to drag off of this and we want to set the visibility of our timer widget.
Remember, we are hiding it right now. And here we want to set the visibility to be on so very important that you check that box right there that's going to indicate that you should be turning it on. All right, next, we're going to take our es FX white magic lens active sound. I'm going to drag and drop this component in here. Drag off of it. And we're going to say activate.
Remember, this sound effect, this sound component, I should say, was D activated coming under our Details panel. It is not set to be auto activated. So in this function is where we're going to say, hey, play that sound. Okay, scooching on over to the right a little bit, let me just maximize my screen real estate a little bit. After this, we're going to bring in a sequence node. quick way to do that hold down the S key and left click there is a sequence node.
And I'm doing this more for cleanliness sake here I'm gonna have something branch off of here as well as here. Let's work off of the then zero branch first. First thing I'm going to do is drag off in type in, get all actors of class right here under the utility section, get all actors of class. Get all actors of what class Well, I want to grab all actors have my wall, my BP secret wall. And this is going to spit out an array of actors so that if we have multiples of them placed into the level, it'll get them all. And out of my out actors I'm going to drag out and type in for each.
We're going to bring in a for each loop. So for each of our secret walls, we want to do something. Well what do we want to do for each one of these? We're going to grab out of our array element, meaning for each one of these, we're going to get our mesh, get the mesh and then we are going to drag off of this and we are going to set the material. So the loop body plugs into the material here. And what do we want to set our material here?
Well, we created our m underscore lens of the Lens of Truth wall m Lens of Truth wall. So this is what is going to change the material of the wall that have that kind of purple see through look. Okay, so that's pretty good. Next let's work off of the then one branch. We're gonna drag off of here we're gonna get all actors of class right here in the utility section, get all actors of class. Here we want to find our platform, our BP secret platform.
So up here was the wall down here we're dealing with our platform. Let's drag off of it and bring in a for each loop. Make sure you plug in that execution layer. For each of these, we are going to drag off the array element and get mesh. There it is or get mesh. And we're going to drag off of this a few times because there's much that we want to alter about this when we turn on our Lens of Truth.
First thing we're going to do is drag off of this and type in set visibility. For our platform, it's going to be hidden by default. So we're going to turn our visibility on. And just to double check here, let me go back to my actors, secret platform viewports currently, my mesh here. coming under here, currently, I do have it set to visible by default. So I should check this to I should say rather uncheck it so that we are not seeing that by default.
So go to your secret platform, select your mesh in the Details panel, let's uncheck the visible the visible checkbox here to make sure that it is hidden by default. Okay. Let me jump back to my BP player. Because here in our lens on function, we're saying hey, all secret platforms, we're going to get your mesh and now we're going to make it visible. Okay, that's not the only thing we're going to do off of our mesh here. Let's drag off of our mesh again, and we're going to set a material.
I'm going to hook in my execution wires like so. Our material for this one is going to be our Lens of Truth. And I spelled truth wrong Lens of Truth platform that yellowish one. Then I'm going to drag off of my mesh again, and I want to set collision enable, there's a function for it. Set collision enabled, make sure the execution wire is flowing into that as well. Let's bring our mesh on down a little bit.
And here I'm gonna set the collision type to be collision enabled query and physics. So that'll make it so that we can actually land on our platform. Remember here in our BP secret platform with our mesh selected by come under the collision section currently, by default, the collision is set to have no collision. Here in our BP player in our lens on function, this is where we're actually enabling it. Okay, and then let's drag off of our mesh one more time and type in set collision. And I'm looking for response to Chanel that's channel and I will hook in our execution wires.
Like so. And I am going to change the channel to be world dynamic. And the new response here is going to be blocked. What is this gonna do? Well, right up evolve, we're saying hey enable collision down below here we're saying we want our response here to now be blocked so that it is going to make it so that it can block things our character doesn't just pass right through it. Alright, so that is going to be our lens on effects.
With that done. Let's compile here to see if we made any mistakes. doesn't look that way. And then save. And now we're ready to move on to the lens off effects. So let's create a new function for that.
Come under my blueprints function, click the plus button to add a new function, lens FX underscore off and we're going to start This off by setting RB is using lens Let me hold down the Alt key and left click, drag one of these in and when you hold down the Alt key and left click, that brings in a setter right away. We're gonna set this to false. So when our lens effects is off, we want to say hey, we are no longer using the lens. Let's drag off of this type in play sound 2d. And the sound that we want to slot in here is going to be deject. Mm hmm.
Excuse me, eject from player Q. There we go. Then we are going to bring in our widget. Again, our w magic timer widget. We're going to grab off of this say set visibility and when we are turning off this effect, we want the visibility Have you to be checked off so make sure that that is unchecked. Then we are going to get our es FX white magic lens active component, we're going to grab that Drag off of that.
And here we're going to type in fade out, there's an audio function for fading out. So that's gonna fade out that sound effect that is playing. Let's set the fade out duration to be one second show. And the fade volume level zero is what we want. Then let's bring in the sequence node. S key left click to quickly grab a sequence node.
And just like we did before, we're going to build a little little bit off the then zero branch and then off of the event one branch. These then zero branch is going to deal with our secret wall. So let's right click. Let's get all actors of class get all actors of class. Click this drop down we are referring to our secret wall secret wall up here. Let's drag out of the out actors that's going to get all secret walls for each, we want the for each loop, make sure you hook in the execution wire.
And then for each of these, we're going to drag out of our array elements, we're gonna get our mesh once again, I suppose it could have copied and pasted a lot of this from our lens on function that we created. But that's okay, we get to redo this again, see how this is all flowing together and let's set the material. Practice makes perfect. And the material we want to change this back to is the original which is our brick, underscore, clay. underscore old. All right, so that's looking good.
Let's now work under the then one output pin. Let's get all actors of class, get actors, act tours of class. There it is get all actors of class. Here we're going to be dealing with our platform, get all secret platforms, drag out of the out actors and bring in another for each loop. Let's drag off the array element and get our mesh. And much like we did before, we're going to drag off of our mesh, we're going to set the visibility and whereas before we were toggling it on here, we want this unchecked, we want it to not be visible.
Let's drag off of our mesh one more time. Let's set material Let's set our material back to our brick clay. Well actually, we don't even need to set a material for this because we are setting it hidden. So this is, this is technically not something you need to do. If it's visible, you don't even need to see the original material on it, so it doesn't really matter. In fact, I think I'll even skip that step right there.
But let's drag off of our mesh and let's do set collision enabled. And here we are going to leave it as no collision, we do not want to collide with it if we can't see it. Let's Compile and Save. And I'll try to frame this all up so you can see exactly what we have for our lens off function right here. Here's the first part of the lens off function. That's eject from player that is in the engine sounds By the way, of course slot in whatever Do you want sliding over to the right here is the right most part of our lens f x off.
And then our lens FX on. looks kind of like this. That's the first part. And then the second part, make sure you got all the appropriate boxes checked in terms of like the visibility and whatnot. I'll scroll down this one's a little bit tough to see. And right there.
Okay, I'm gonna save this one more time. Now, we can't actually check this out yet because we're not actually calling these functions yet that we will get going soon enough. But that'll do it all for this video guys. We will see you in the next one.