WEBVTT

00:07.070 --> 00:08.270
Welcome back.

00:08.300 --> 00:12.340
We're going to continue our work with our electrocute ability.

00:12.350 --> 00:19.430
But if we go to class settings we see that it's based on or damage gameplay ability our base damage

00:19.430 --> 00:21.050
gameplay ability class.

00:21.230 --> 00:28.130
Now electrocute is going to be one of the more advanced gameplay abilities we create in this course.

00:28.130 --> 00:34.850
It's actually going to have a lot to it, and that means we're going to need a base C plus plus class

00:34.850 --> 00:42.860
behind it, because there will be some algorithmic operations, and for algorithms, it's best to do

00:42.860 --> 00:46.310
those in C plus plus and expose those to blueprint.

00:46.340 --> 00:53.300
It's always more performant to call a blueprint callable function that has C plus plus code underpinning

00:53.300 --> 00:59.900
what it does, rather than a blueprint function that has its logic all scripted out in blueprint.

00:59.930 --> 01:06.110
It's much more performant and fast to do the heavy lifting in C plus plus, and that's why we can get

01:06.110 --> 01:12.590
away with having the majority of our logic flow in a gameplay ability blueprint, because we're wise

01:12.590 --> 01:17.810
about keeping those computationally intense algorithms on the C plus plus side.

01:17.840 --> 01:27.440
So we're going to create a new gameplay ability for our electrocute, but really, it's a spell that

01:27.440 --> 01:29.090
casts a beam.

01:29.690 --> 01:38.660
And just so we remember the end goal here, if we go to Effects Shock and check out this beam, we have

01:38.660 --> 01:40.280
a beam of electricity.

01:40.310 --> 01:46.430
So the spell is concerned with some kind of a beam effect.

01:46.430 --> 01:51.580
And we're going to flesh out the mechanics of that type of gameplay ability.

01:51.590 --> 01:54.710
So we're going to make an aura beam spell.

01:55.330 --> 02:00.940
So we can go to C plus plus classes or public ability system abilities.

02:01.060 --> 02:03.520
And we'll make a new C plus plus class.

02:03.520 --> 02:06.940
And this needs to be a damage gameplay ability.

02:06.940 --> 02:10.330
So we're going to base this on aura damage gameplay ability.

02:10.420 --> 02:14.050
We'll create a new C plus plus class derived from this.

02:14.050 --> 02:19.120
And we're going to call this Aura Beam spell.

02:19.540 --> 02:22.960
We'll go ahead and create the class and close the editor down.

02:25.080 --> 02:31.020
All right, there's aura Beam spell CP, and I'll open the H file as well.

02:31.020 --> 02:33.810
And now we have the C plus plus class.

02:33.810 --> 02:39.870
And as we're constructing our gameplay ability we'll be coming back to this class and adding things

02:39.870 --> 02:47.190
to it and using it in the electrocute blueprint, which we now need to reparent to or a beam spell.

02:47.190 --> 02:48.840
So we're going to do that next.

02:48.960 --> 02:50.730
So launching the editor.

02:52.480 --> 02:54.850
We'll go ahead and get that ability back open.

02:55.090 --> 02:59.350
I don't think I need BP or a character or Firebolt at the moment.

02:59.350 --> 03:04.690
I'm just going to come back to electrocute, come to its class settings and change them from aura damage

03:04.690 --> 03:07.990
gameplay ability to Aura Beam spell.

03:08.760 --> 03:14.250
Now we can use that as our parent class to underpin what goes on in here.

03:14.490 --> 03:18.360
Now, I think I'm done with all these print strings, at least for now.

03:18.390 --> 03:21.990
You know how much I like my print strings, but I'm going to get rid of them for now.

03:22.020 --> 03:24.030
We'll keep the weight input release.

03:24.030 --> 03:25.440
We're going to be using that.

03:25.440 --> 03:26.040
Right.

03:26.040 --> 03:28.830
But let's think about what's happening here.

03:28.830 --> 03:32.730
When we activate electrocute we're pressing some kind of input.

03:32.760 --> 03:36.060
We're going to need to get some target data under the mouse.

03:36.060 --> 03:38.400
Just like for the Firebolt spell.

03:38.400 --> 03:41.670
If we launch a Firebolt we've clicked somewhere.

03:41.670 --> 03:41.970
Right.

03:41.970 --> 03:50.400
And that means we're going to need a location and really just a full on hit result for that place where

03:50.400 --> 03:51.390
we're clicking.

03:51.390 --> 03:57.150
And it doesn't matter if our input is a left mouse button or right mouse button, even one of the number

03:57.150 --> 03:58.650
keys or anything else.

03:58.680 --> 04:04.890
All that matters is where our mouse is at the time, so we can get that target data under the mouse

04:04.890 --> 04:07.350
with our custom ability task.

04:07.380 --> 04:09.720
Target data under mouse.

04:09.720 --> 04:12.270
We'll go ahead and get one of those first thing.

04:12.870 --> 04:15.300
And as soon as we have valid data.

04:16.010 --> 04:25.340
Then we know that we'll have our data handle, which if we go ahead and call, get hit result from target

04:25.340 --> 04:26.090
data.

04:27.010 --> 04:32.290
Then we know that we can get from our hit result really anything we want.

04:32.320 --> 04:39.220
The things we're most interested in are the impact point, not impact normal and the hit actor.

04:39.310 --> 04:41.710
Those are the things we're most interested in.

04:41.710 --> 04:48.640
And since we'll be using that impact point and the hit actor all throughout the game play ability,

04:48.760 --> 04:54.970
right, we're going to need to know where to set the end location for our beam when we spawn it.

04:54.970 --> 05:01.090
And we're also going to need to know who the hit actor is, if we're going to cause damage to it and

05:01.090 --> 05:02.020
things like that.

05:02.050 --> 05:04.420
We're going to want to store those.

05:04.420 --> 05:07.000
We can promote those two variables, right.

05:07.000 --> 05:13.840
But because we're going to probably want to use these in our algorithms, some of which we may program

05:13.840 --> 05:14.380
in C plus.

05:14.380 --> 05:22.180
Plus, it might be a good idea for this spell to have a hit actor and a mouse hit location variable

05:22.210 --> 05:30.100
a C plus plus variable that we can set from blueprint and that's going to make things easier for us

05:30.100 --> 05:31.430
in C plus plus.

05:31.450 --> 05:35.410
Now in addition to this while I'm in the shock loop.

05:35.410 --> 05:41.170
In other words, while I'm electrocuting an enemy and that beam is showing, I'm going to want to hide

05:41.170 --> 05:48.400
the mouse cursor, and I want that cursor to come back as soon as I have released my input.

05:48.400 --> 05:55.930
And for that reason, I'm also going to want the owner controller, a player controller variable that

05:55.930 --> 05:57.580
we can get as well.

05:57.580 --> 06:00.610
So I'm going to want variables for those.

06:00.610 --> 06:07.480
And we can also make a blueprint callable function to pass info into so that we can set those variables

06:07.480 --> 06:08.230
values.

06:08.230 --> 06:13.540
So I'm going to go ahead and close the editor and add some things to my beam spell.

06:13.540 --> 06:19.810
And we'll go ahead and make a public section and a protected section.

06:19.810 --> 06:23.980
And in the protected section is where I'd like my variables.

06:23.980 --> 06:32.020
So first I'd like to store my mouse hit location as an f vector called mouse hit location.

06:34.580 --> 06:39.290
And I'd like to be able to set this from within the blueprint, which means I want it to be blueprint.

06:39.290 --> 06:40.310
Read, write.

06:40.610 --> 06:43.640
I'm going to go ahead and stick this in the category.

06:45.370 --> 06:46.660
Of beam.

06:48.160 --> 06:50.860
And I'll go ahead and make an A actor pointer.

06:50.900 --> 06:58.660
That'll be a T object pointer to type a actor called mouse hit actor.

07:01.470 --> 07:03.330
And this one will also be blueprint.

07:03.330 --> 07:03.570
Read.

07:03.570 --> 07:04.380
Write.

07:06.060 --> 07:07.980
Now we're making a blueprint read, write.

07:07.980 --> 07:15.210
But I would also like a nice function that can take in that hit result and set those properties for

07:15.210 --> 07:15.790
us.

07:15.810 --> 07:25.140
So I'm going to make a void function for caching off our pertinent values that we need here in this

07:25.140 --> 07:25.950
ability.

07:25.980 --> 07:30.930
So we can make a store mouse data info.

07:31.930 --> 07:39.700
Which can take in a const f hit result by reference, and we can call this hit result.

07:40.990 --> 07:44.560
And we'll make this a new function with blueprint callable.

07:44.950 --> 07:48.550
Now I mentioned we'll want a player controller as well.

07:48.550 --> 07:53.800
So I'm going to make a t object pointer of type A player controller.

07:55.520 --> 07:58.850
And we'll call this owner player controller.

07:59.960 --> 08:01.580
We'll make this also blueprint.

08:01.580 --> 08:01.850
Read.

08:01.850 --> 08:02.630
Write.

08:03.690 --> 08:07.830
And we'll just go ahead and make a separate function for setting this.

08:09.070 --> 08:10.120
Store owner.

08:10.120 --> 08:10.480
Player.

08:10.480 --> 08:11.470
Controller.

08:13.030 --> 08:15.580
And we'll make this blueprint callable as well.

08:17.710 --> 08:25.600
We can handle storing it in store mouse data info, but store mouse data info has a function name that

08:25.600 --> 08:27.490
doesn't indicate that it does that at all.

08:27.490 --> 08:33.010
So we'll just go ahead and have two separate functions that take care of these.

08:33.310 --> 08:36.070
I'll go ahead and generate these function definitions.

08:36.880 --> 08:46.480
In storm mouse data info can check to make sure if the hit result dot be blocking hit is true, and

08:46.480 --> 08:55.180
if it is, we'll get that mouse hit location and we'll store it with our hit result dot impact point.

08:55.360 --> 09:02.200
And we'll also get our mouse hit actor and we'll store that as well with hit results.

09:02.410 --> 09:03.970
Dot get actor.

09:04.510 --> 09:11.950
Now if our hit result doesn't get a valid blocking hit, we can simply cancel the ability with cancel

09:11.950 --> 09:12.790
ability.

09:13.030 --> 09:16.090
Now, to cancel the ability, we have to pass in some things.

09:16.090 --> 09:20.020
But inside of the game play ability, we have those things.

09:20.020 --> 09:27.370
The first is the ability spec handle we can pass in current spec handle we just automatically have access

09:27.370 --> 09:28.120
to that.

09:28.120 --> 09:29.980
It needs the actor info.

09:29.980 --> 09:37.750
We can get current actor info, pass that in, and then it wants to know if we should replicate this

09:37.750 --> 09:39.430
canceling of the ability.

09:39.430 --> 09:45.580
And we also need the activation info we can pass in current activation info.

09:45.610 --> 09:46.720
We have that as well.

09:46.720 --> 09:51.880
And finally a boolean for whether or not to replicate canceling this ability we can pass in.

09:51.880 --> 09:52.450
True.

09:52.690 --> 09:56.860
So now we have our mouse hit location and mouse hit actor.

09:56.860 --> 10:02.770
If we call this function and to store the player controller, we can get the current actor info.

10:04.140 --> 10:06.720
And we have access to the avatar actor.

10:06.930 --> 10:09.410
We have access to the player controller.

10:09.420 --> 10:14.940
So really, it's not that important to store this as a variable as we already have this.

10:14.940 --> 10:17.580
But what we can do is we can store it anyway.

10:17.580 --> 10:19.560
This is a weak object pointer.

10:19.560 --> 10:28.140
So because our variable is a new property, it's not a weak object pointer, which means that it affects

10:28.140 --> 10:30.570
reference counting for the player controller.

10:30.570 --> 10:33.030
But our player controller should be persistent.

10:33.030 --> 10:38.280
So we're going to say if we'll go ahead and check current actor info.

10:40.730 --> 10:43.940
And we'll set our player controller variable.

10:44.690 --> 10:45.170
Owner.

10:45.170 --> 10:45.500
Player.

10:45.500 --> 10:46.520
Controller.

10:49.190 --> 10:53.210
Equal to current actor info player controller.

10:53.210 --> 10:58.190
And because this is a weak object pointer, we'll need to call get on it.

10:58.610 --> 11:01.820
And now we'll have our owner player controller.

11:01.820 --> 11:03.980
And these are exposed to blueprint.

11:03.980 --> 11:07.220
So we can go ahead and store this information.

11:07.220 --> 11:09.800
Let's go ahead and run in debug mode.

11:12.390 --> 11:14.850
And we can get that ability back open.

11:14.850 --> 11:19.170
And as soon as we have valid data, I'd like to store that mouse info.

11:19.170 --> 11:23.130
So I'm going to say store mouse data info.

11:23.130 --> 11:24.930
And this takes in a hit result.

11:24.930 --> 11:27.510
So we don't even need to break the hit result anymore.

11:27.540 --> 11:29.580
We can just pass this straight in.

11:30.970 --> 11:33.310
As soon as we have valid data, that's fine.

11:33.310 --> 11:34.840
And we also have.

11:36.920 --> 11:37.850
Store owner.

11:37.850 --> 11:38.180
Player.

11:38.180 --> 11:39.110
Controller.

11:41.090 --> 11:44.550
And this function doesn't need to have anything passed in.

11:44.570 --> 11:49.580
It's just going to get the player controller from the current actor info.

11:49.910 --> 11:54.770
Okay, so as soon as that stuff is done, we can do a number of things here.

11:54.800 --> 11:58.950
The first of which I'd like to do is to hide the mouse cursor.

11:58.970 --> 12:05.200
So as soon as we have valid data here, we're going to do some additional things here.

12:05.210 --> 12:10.700
So we can consider this to be sort of the setup of our ability first and foremost.

12:10.730 --> 12:15.710
We get that data from the mouse cursor and then we can start doing things.

12:15.890 --> 12:17.870
I'm going to make a sequence note here.

12:18.140 --> 12:24.680
And the first thing I'd like to do is hide the mouse cursor by getting our owner player controller.

12:28.050 --> 12:31.590
And setting the show mouse cursor.

12:31.590 --> 12:32.400
Boolean.

12:33.420 --> 12:34.920
I'd like to set it to false.

12:35.940 --> 12:37.740
So I'm going to do that first.

12:40.740 --> 12:45.300
And we'll do a number of other things, but that's number one.

12:45.630 --> 12:49.080
And we'll also wait for the input to be released.

12:49.080 --> 12:53.700
And as soon as we do have a release, we can show that mouse cursor again.

12:53.700 --> 13:00.450
So we can take these nodes and we can paste them and hook them up to on release and show that mouse

13:00.450 --> 13:01.500
cursor here.

13:02.630 --> 13:06.110
Now just so we can activate this multiple times.

13:06.110 --> 13:08.180
I'm going to go ahead and end the ability here.

13:11.270 --> 13:18.230
And the result of this is that, well, we should see our mouse cursor go away and come back when we

13:18.230 --> 13:20.270
let up on that input.

13:20.270 --> 13:22.760
And we can test that by right clicking.

13:22.760 --> 13:26.990
There goes the mouse and un clicking and it comes back right.

13:26.990 --> 13:32.570
So pretty simple but a pretty important step for this gameplay ability.

13:33.840 --> 13:38.430
And of course, we're ending the ability every time that mouse cursor comes back.

13:39.060 --> 13:42.540
So we have a couple of stages here.

13:42.570 --> 13:44.870
The first is very crucial.

13:44.880 --> 13:50.460
We're going to wrap this in a comment that says store target data.

13:51.330 --> 13:55.230
Or we'll say store mouse data variables.

13:55.830 --> 14:00.810
And I'm going to go ahead and give this comment a different color.

14:02.810 --> 14:06.080
So we can make this a little bit more on the pinkish side.

14:08.200 --> 14:09.280
Something like that.

14:09.280 --> 14:12.460
We can even store that color like so.

14:13.650 --> 14:19.680
Actually, that pink is kind of bugging me, so I'm going to change it to more of.

14:21.330 --> 14:22.630
More of a purple.

14:22.650 --> 14:23.070
Yeah.

14:23.070 --> 14:23.760
There we go.

14:26.090 --> 14:31.190
We'll store that one and take that salmon color and bring it out.

14:31.310 --> 14:33.590
We can drag it onto the trashcan there.

14:33.920 --> 14:34.310
Okay.

14:34.310 --> 14:40.760
So we're storing the mouse data variables, hiding the mouse cursor and then on release showing the

14:40.760 --> 14:41.720
mouse cursor.

14:41.810 --> 14:47.050
Now in addition to hiding the mouse cursor, we're going to want to play a montage.

14:47.060 --> 14:47.780
Right.

14:47.780 --> 14:55.250
And the electrocute ability needs a electrocute montage to play.

14:55.280 --> 15:00.520
Now we could make an interface function and keep the electrocute montage on the character.

15:00.530 --> 15:05.060
If we do that, then all characters will have an electrocute montage.

15:05.060 --> 15:12.470
And at that point in a large project, you might start thinking about specializing your character classes

15:12.470 --> 15:18.860
and perhaps even having an interface per character class like you would have an Elementalist interface.

15:18.860 --> 15:25.640
For example, if you had an Elementalist interface, then it could have a function for retrieving an

15:25.640 --> 15:27.470
electrocute montage.

15:27.560 --> 15:29.810
So that's something to keep in mind.

15:30.020 --> 15:35.750
Another option, if you don't want to go through all that trouble, is to have a variable on the electrocute

15:35.780 --> 15:44.030
gameplay ability for the montage, and then if you derive a child of the electrocute gameplay ability

15:44.060 --> 15:47.600
for a different enemy, you can then set that parameter.

15:47.600 --> 15:50.060
And that makes it a little bit more flexible.

15:50.060 --> 15:56.570
So we can make a variable here called electrocute montage.

15:58.750 --> 16:01.960
I'm actually going to call it montage, underscore, electrocute.

16:03.070 --> 16:06.100
And this can be an anim montage.

16:07.780 --> 16:10.390
And we'll make it a object reference.

16:10.390 --> 16:13.030
We'll compile it and we can just set it here.

16:13.030 --> 16:17.290
And that means we'll need to create a montage for aura.

16:17.290 --> 16:18.340
So we'll get to that.

16:18.340 --> 16:20.980
I'm going to go ahead and save everything.

16:20.980 --> 16:23.290
I think this is a good stopping point.

16:23.320 --> 16:27.430
We now have an ability that shows and hides the mouse cursor.

16:27.430 --> 16:30.760
And we're going to soon play that montage.

16:30.760 --> 16:34.990
In the next video, we'll make the montage and get to play in it.

16:35.140 --> 16:35.860
All right.

16:35.890 --> 16:36.670
Great job.

16:36.670 --> 16:37.690
I'll see you soon.
