Welcome to your next quest.
Now this quest is going to be a little bit on the easier side.
Just a little bit of practice for you.
I'd like you to create, show and hide functions for the magic circle in the player interface.
This will allow us to show and hide the magic circle easily, without having to know exactly what class
has that magic circle.
We can just check to see if it implements the interface, and we can show or hide that magic circle.
Now, as a bonus, create a set material function and that way you can change that magic circle material.
If you'd like, you can set that magic circle material.
You can perhaps make a show function that takes in a material.
Maybe your material can be an optional parameter.
So that just makes this system a little bit more versatile.
So pause the video and conquer this quest now.
Okay, so I need a couple of interface functions.
I'm going to close out of the editor and go into my interaction folder, where I have my player interface,
and I'd like to add a function or two here for showing and hiding our magic circle.
So I'm going to make a void show Magic Circle.
And this can take a you material.
And if you wanted to be able to pass in a material instance or just a material, you could pass in a
new material interface, and then it could be either so we can pass in a new material interface.
We can call this decal material.
But I'd like to set it to null pointer by default.
So it's an optional parameter.
And I'd like to make this a blueprint native event and also blueprint callable.
So we'll give it the you function blueprint native event and also blueprint callable so that we can
call that from blueprint say in our arcane shards ability if we wanted to.
So now that we have this we can go into our character.
And I'm going to implement this in our character right under the player interface.
Inside this section here we're going to say virtual void show Magic Circle.
Implementation.
And that's an override.
Okay, so it wasn't popping up.
And that's because I had a typo.
Blueprint native event was missing a T at the end that's going to fix that issue.
So back in our character we'll try this again.
Virtual Void show magic circle implementation.
And I'm going to want a hide magic circle as well.
So we'll go back to our player interface and make a hide version of this.
I'm just going to copy this.
Paste it right underneath and call this hide Magic circle.
And we don't need any input parameters.
And we can implement this in our character as well.
Virtual void hide magic circle implementation.
And we can go ahead and implement both of these.
And we don't need to call super for these.
Or rather the iPlayer interface parent version.
And what we're going to do is I'd like to show and hide the magic circle on the player controller.
So we have our player controller here, which is not dependent on aura character if we search for or
a character.
It's nowhere here in Aura Player Controller, I'm going to have that dependency be one way or a character
is going to depend on aura player controller.
And if we search for or a player controller, we see that in init ability actor info.
We're getting it here so I can just be lazy and copy that if statement and go back to show Magic Circle.
And I can paste it in here.
And now we have our A player controller, but I don't need anything inside that if statement.
I just want to call or a player controller.
Show Magic Circle.
Now we're passing in a decal material that's a material interface, which means if we're going to want
to use that, if it's not a null pointer, we can check if decal material is not equal to null pointer.
Then we're going to want to set that material on the decal.
And for that reason the player controller should be able to do that.
We should have a public function on or a player controller to update the magic circle material.
So we're going to have a new public function right here.
We can just make a set magic circle material or we can make show magic circle take that in as a new
material interface.
And this can be called decal material.
We can set it equal to null pointer by default.
And this function can just take it in.
So show magic circle here can take that in.
And if the magic circle is valid we can then check if decal material.
If that's not a null pointer, then we can take magic circle.
And get its decal component.
Now, if we go to Magic Circle, Magic Circle decal is protected.
Rather than go through the step of making a public getter for it, I'm just going to make it public.
And then here in our player controller, I'm going to get the Magic Circle decal, and I'm going to
call set material and pass in decal material.
And of course this needs an element index.
We're going to pass in zero.
It's just going to have one.
And so only if that decal material isn't null then we'll set that to and we can test that as well.
So now that the player controller takes in a material which is optional, we can now go into our character.
And when calling Show Magic Circle we can then pass along that decal material.
And or a player controller show magic circle.
We don't need to check null here.
We check for null in the player controller function and.
For Hide Magic circle implementation, we can just call Hide Magic Circle.
Simple as that.
And now that we have these functions, we can use them to show or hide the magic circle.
And with that, we can compile and test out our new functions.
Okay.
So I'm going to open up those asset editors.
I'm no longer going to do anything in the player controller begin play.
I'm just going to close out of it.
After removing all that stuff.
For now, I'll just leave The Magic Circle's tick just for fun.
And I'm going to go into another class, perhaps my character class in character, or a BP or a character.
And I'm going to call my interface function from here and begin play.
So I'm going to get my event, begin play.
And I'm going to just right click and call Show Magic Circle and get that player interface function.
And I'm just going to get a reference to self.
And pass that into the target there and just call Show Magic Circle.
We're just going to see what this looks like if we press play.
Saving all first and we see our magic circle.
Now, what about this decal material?
What if we pass something in here?
Well, we can test that out by going to Content assets magic circles.
And we can take our Magic Circle one.
And we can go ahead and say create a material instance out of it.
Call it my magic circle underscore.
Let's call it underscore blue.
And here in our magic circle we have an emissive color.
And this is a parameter.
So since we created a material instance we have this emissive color override.
And I just clicked on set the preview mesh to a plain primitive.
And I'm going to change this color override to a blue color.
Because why not?
We'll go ahead and save that.
And here in our character, we can pass in my magic circle blue.
Compile save, press play.
And we have a blue magic circle.
So this is kind of cool.
Now notice that if I'm hovering over the enemy, we don't see that magic circle because we're no longer
setting its location to the ground if we hover over the enemy's foot on its toe, yes, we see it,
but if that location is too high, we're not going to project that magic circle onto the floor.
And that's just due to my Magic Circle's decal component here being just so short.
If you want it taller again, you could make it taller.
And then if you're hovering right over the enemy, we'll see it.
And it looks kind of cool with the enemy standing in the center of the circle.
Looks kind of ominous for that enemy, like it's about to get hurt really badly.
Okay, so now we have interface functions.
The aura character can show it.
I don't think we need to test hide magic circle.
I think we know it's going to work.
So with that we now have the ability to show and hide magic circles, which is going to come in really
handy for our Arcane Shards ability.
And we're going to get started making that spell next.
Excellent job.
Great job on the quest and I'll see you soon.