WEBVTT

00:00.600 --> 00:02.310
Welcome to your next quest.

00:02.340 --> 00:06.300
Now this quest is going to be a little bit on the easier side.

00:06.300 --> 00:08.610
Just a little bit of practice for you.

00:08.640 --> 00:13.890
I'd like you to create, show and hide functions for the magic circle in the player interface.

00:13.890 --> 00:20.700
This will allow us to show and hide the magic circle easily, without having to know exactly what class

00:20.700 --> 00:22.170
has that magic circle.

00:22.170 --> 00:28.080
We can just check to see if it implements the interface, and we can show or hide that magic circle.

00:28.080 --> 00:34.710
Now, as a bonus, create a set material function and that way you can change that magic circle material.

00:34.710 --> 00:38.130
If you'd like, you can set that magic circle material.

00:38.130 --> 00:42.630
You can perhaps make a show function that takes in a material.

00:42.630 --> 00:45.270
Maybe your material can be an optional parameter.

00:45.270 --> 00:48.450
So that just makes this system a little bit more versatile.

00:48.450 --> 00:51.630
So pause the video and conquer this quest now.

00:54.710 --> 00:57.350
Okay, so I need a couple of interface functions.

00:57.350 --> 01:03.470
I'm going to close out of the editor and go into my interaction folder, where I have my player interface,

01:03.470 --> 01:09.800
and I'd like to add a function or two here for showing and hiding our magic circle.

01:09.800 --> 01:13.520
So I'm going to make a void show Magic Circle.

01:14.900 --> 01:17.750
And this can take a you material.

01:17.750 --> 01:24.680
And if you wanted to be able to pass in a material instance or just a material, you could pass in a

01:24.680 --> 01:29.870
new material interface, and then it could be either so we can pass in a new material interface.

01:29.870 --> 01:32.720
We can call this decal material.

01:33.900 --> 01:36.870
But I'd like to set it to null pointer by default.

01:36.870 --> 01:38.700
So it's an optional parameter.

01:38.700 --> 01:43.020
And I'd like to make this a blueprint native event and also blueprint callable.

01:43.020 --> 01:49.080
So we'll give it the you function blueprint native event and also blueprint callable so that we can

01:49.080 --> 01:54.090
call that from blueprint say in our arcane shards ability if we wanted to.

01:54.420 --> 01:57.720
So now that we have this we can go into our character.

01:57.720 --> 02:03.570
And I'm going to implement this in our character right under the player interface.

02:03.570 --> 02:10.050
Inside this section here we're going to say virtual void show Magic Circle.

02:12.240 --> 02:13.590
Implementation.

02:14.910 --> 02:16.470
And that's an override.

02:18.370 --> 02:20.770
Okay, so it wasn't popping up.

02:20.770 --> 02:22.570
And that's because I had a typo.

02:22.570 --> 02:27.430
Blueprint native event was missing a T at the end that's going to fix that issue.

02:27.430 --> 02:30.190
So back in our character we'll try this again.

02:30.190 --> 02:34.690
Virtual Void show magic circle implementation.

02:34.690 --> 02:37.690
And I'm going to want a hide magic circle as well.

02:37.690 --> 02:42.370
So we'll go back to our player interface and make a hide version of this.

02:42.370 --> 02:43.990
I'm just going to copy this.

02:45.400 --> 02:49.270
Paste it right underneath and call this hide Magic circle.

02:49.660 --> 02:52.540
And we don't need any input parameters.

02:53.170 --> 02:56.020
And we can implement this in our character as well.

02:56.050 --> 03:01.870
Virtual void hide magic circle implementation.

03:01.870 --> 03:04.720
And we can go ahead and implement both of these.

03:06.690 --> 03:09.660
And we don't need to call super for these.

03:10.770 --> 03:14.610
Or rather the iPlayer interface parent version.

03:14.610 --> 03:20.640
And what we're going to do is I'd like to show and hide the magic circle on the player controller.

03:21.030 --> 03:27.810
So we have our player controller here, which is not dependent on aura character if we search for or

03:27.810 --> 03:28.920
a character.

03:29.070 --> 03:35.790
It's nowhere here in Aura Player Controller, I'm going to have that dependency be one way or a character

03:35.790 --> 03:38.340
is going to depend on aura player controller.

03:40.000 --> 03:45.580
And if we search for or a player controller, we see that in init ability actor info.

03:45.580 --> 03:53.920
We're getting it here so I can just be lazy and copy that if statement and go back to show Magic Circle.

03:53.920 --> 03:55.450
And I can paste it in here.

03:55.450 --> 04:00.520
And now we have our A player controller, but I don't need anything inside that if statement.

04:00.520 --> 04:03.430
I just want to call or a player controller.

04:06.250 --> 04:08.410
Show Magic Circle.

04:09.010 --> 04:15.550
Now we're passing in a decal material that's a material interface, which means if we're going to want

04:15.550 --> 04:26.470
to use that, if it's not a null pointer, we can check if decal material is not equal to null pointer.

04:27.400 --> 04:31.510
Then we're going to want to set that material on the decal.

04:31.510 --> 04:35.260
And for that reason the player controller should be able to do that.

04:35.260 --> 04:40.300
We should have a public function on or a player controller to update the magic circle material.

04:40.300 --> 04:44.500
So we're going to have a new public function right here.

04:44.620 --> 04:52.180
We can just make a set magic circle material or we can make show magic circle take that in as a new

04:52.180 --> 04:53.770
material interface.

04:53.770 --> 04:56.410
And this can be called decal material.

04:56.410 --> 04:59.170
We can set it equal to null pointer by default.

04:59.170 --> 05:01.750
And this function can just take it in.

05:01.750 --> 05:05.680
So show magic circle here can take that in.

05:05.680 --> 05:11.980
And if the magic circle is valid we can then check if decal material.

05:13.490 --> 05:17.360
If that's not a null pointer, then we can take magic circle.

05:19.050 --> 05:21.030
And get its decal component.

05:21.060 --> 05:24.660
Now, if we go to Magic Circle, Magic Circle decal is protected.

05:24.750 --> 05:32.610
Rather than go through the step of making a public getter for it, I'm just going to make it public.

05:32.610 --> 05:38.760
And then here in our player controller, I'm going to get the Magic Circle decal, and I'm going to

05:38.760 --> 05:45.120
call set material and pass in decal material.

05:45.120 --> 05:48.360
And of course this needs an element index.

05:48.360 --> 05:49.650
We're going to pass in zero.

05:49.650 --> 05:50.880
It's just going to have one.

05:50.880 --> 05:57.240
And so only if that decal material isn't null then we'll set that to and we can test that as well.

05:57.240 --> 06:05.430
So now that the player controller takes in a material which is optional, we can now go into our character.

06:05.430 --> 06:12.600
And when calling Show Magic Circle we can then pass along that decal material.

06:13.750 --> 06:16.480
And or a player controller show magic circle.

06:16.480 --> 06:17.890
We don't need to check null here.

06:17.890 --> 06:22.990
We check for null in the player controller function and.

06:23.800 --> 06:30.130
For Hide Magic circle implementation, we can just call Hide Magic Circle.

06:30.900 --> 06:32.160
Simple as that.

06:32.160 --> 06:38.070
And now that we have these functions, we can use them to show or hide the magic circle.

06:38.070 --> 06:42.030
And with that, we can compile and test out our new functions.

06:43.190 --> 06:43.610
Okay.

06:43.610 --> 06:46.040
So I'm going to open up those asset editors.

06:46.040 --> 06:50.030
I'm no longer going to do anything in the player controller begin play.

06:50.030 --> 06:51.740
I'm just going to close out of it.

06:51.740 --> 06:53.690
After removing all that stuff.

06:53.690 --> 06:57.560
For now, I'll just leave The Magic Circle's tick just for fun.

06:57.560 --> 07:07.280
And I'm going to go into another class, perhaps my character class in character, or a BP or a character.

07:07.280 --> 07:11.180
And I'm going to call my interface function from here and begin play.

07:11.510 --> 07:14.120
So I'm going to get my event, begin play.

07:15.430 --> 07:22.720
And I'm going to just right click and call Show Magic Circle and get that player interface function.

07:23.550 --> 07:25.920
And I'm just going to get a reference to self.

07:26.960 --> 07:31.640
And pass that into the target there and just call Show Magic Circle.

07:31.640 --> 07:34.310
We're just going to see what this looks like if we press play.

07:35.220 --> 07:38.940
Saving all first and we see our magic circle.

07:39.780 --> 07:42.480
Now, what about this decal material?

07:42.510 --> 07:44.730
What if we pass something in here?

07:44.760 --> 07:51.780
Well, we can test that out by going to Content assets magic circles.

07:51.780 --> 07:54.360
And we can take our Magic Circle one.

07:54.360 --> 08:00.240
And we can go ahead and say create a material instance out of it.

08:00.240 --> 08:05.310
Call it my magic circle underscore.

08:05.310 --> 08:07.200
Let's call it underscore blue.

08:07.620 --> 08:12.210
And here in our magic circle we have an emissive color.

08:12.210 --> 08:14.850
And this is a parameter.

08:14.850 --> 08:20.400
So since we created a material instance we have this emissive color override.

08:20.400 --> 08:24.960
And I just clicked on set the preview mesh to a plain primitive.

08:24.960 --> 08:28.530
And I'm going to change this color override to a blue color.

08:29.120 --> 08:30.800
Because why not?

08:30.800 --> 08:32.690
We'll go ahead and save that.

08:32.690 --> 08:39.740
And here in our character, we can pass in my magic circle blue.

08:41.110 --> 08:43.690
Compile save, press play.

08:43.960 --> 08:46.120
And we have a blue magic circle.

08:46.120 --> 08:47.800
So this is kind of cool.

08:47.920 --> 08:55.120
Now notice that if I'm hovering over the enemy, we don't see that magic circle because we're no longer

08:55.120 --> 09:01.270
setting its location to the ground if we hover over the enemy's foot on its toe, yes, we see it,

09:01.270 --> 09:06.460
but if that location is too high, we're not going to project that magic circle onto the floor.

09:06.460 --> 09:12.760
And that's just due to my Magic Circle's decal component here being just so short.

09:12.760 --> 09:15.850
If you want it taller again, you could make it taller.

09:15.850 --> 09:20.020
And then if you're hovering right over the enemy, we'll see it.

09:20.020 --> 09:23.590
And it looks kind of cool with the enemy standing in the center of the circle.

09:23.590 --> 09:29.290
Looks kind of ominous for that enemy, like it's about to get hurt really badly.

09:29.590 --> 09:32.560
Okay, so now we have interface functions.

09:32.560 --> 09:35.080
The aura character can show it.

09:35.080 --> 09:38.050
I don't think we need to test hide magic circle.

09:38.050 --> 09:39.670
I think we know it's going to work.

09:39.670 --> 09:45.940
So with that we now have the ability to show and hide magic circles, which is going to come in really

09:45.940 --> 09:48.880
handy for our Arcane Shards ability.

09:48.880 --> 09:52.210
And we're going to get started making that spell next.

09:52.210 --> 09:53.170
Excellent job.

09:53.170 --> 09:56.260
Great job on the quest and I'll see you soon.
