WEBVTT

00:07.230 --> 00:08.540
Welcome back.

00:08.550 --> 00:14.190
Now, all we're doing in this electrocute spell pretty much is hiding the mouse cursor and showing it

00:14.190 --> 00:14.790
again.

00:14.790 --> 00:16.860
We're going to need to do better than that.

00:16.860 --> 00:18.090
In this video.

00:18.090 --> 00:19.620
We're going to play a montage.

00:19.620 --> 00:22.590
Now we've added a montage electrocute variable.

00:22.590 --> 00:25.350
But we don't have an electrocute montage for aura.

00:25.620 --> 00:27.240
So we're going to make one.

00:27.270 --> 00:32.160
Let's go to assets characters aura animations abilities.

00:32.160 --> 00:35.910
And there should be a cast shock.

00:36.060 --> 00:38.340
We can open that and see what it looks like.

00:38.340 --> 00:41.160
And it's a really short animation.

00:41.160 --> 00:43.950
It's just the beginning of a shock.

00:45.140 --> 00:48.320
Or electrocute if you want to call it ability.

00:48.470 --> 00:53.480
Now we have cast shock and we have cast shock loop and the loop is different.

00:53.480 --> 00:58.020
Remember we added this to our state machine in the animation blueprint.

00:58.040 --> 01:03.080
She'll be in this state when her in shock loop boolean is set.

01:03.110 --> 01:05.570
That's something we have to remember to do.

01:05.810 --> 01:12.500
And we even created an interface function, a blueprint implementable event that we can set when we're

01:12.500 --> 01:13.610
in the shock loop.

01:13.610 --> 01:15.740
So we'll remember to do that.

01:15.860 --> 01:19.640
But for now I'd like to make a montage for Cast Shock.

01:19.670 --> 01:24.260
This really, really short animation will make a montage out of that.

01:24.380 --> 01:30.410
And before we make that, I'm going to scroll down and make sure that enable root motion is checked.

01:30.410 --> 01:31.700
And it is.

01:31.700 --> 01:33.730
So we can make a montage out of shock.

01:33.740 --> 01:42.350
Let's right click create create and Add montage and we'll call this m underscore cast underscore electrocute.

01:43.900 --> 01:47.290
And electrocute is going to get a couple of things right.

01:47.290 --> 01:52.000
We're going to need a motion warping notify state.

01:52.000 --> 01:55.840
So I'm going to change the name of this notify track to motion warping.

01:56.080 --> 01:59.710
And I'm going to make another notify track for events.

02:00.190 --> 02:02.650
And we'll add our notify state.

02:02.650 --> 02:07.450
So I'm going to right click right here add notify state.

02:07.480 --> 02:09.250
Choose motion warping.

02:09.370 --> 02:16.180
And we'll go ahead and motion warp up to just before she juts out the staff.

02:16.180 --> 02:21.280
So right about here and we need to go to the details panel.

02:21.430 --> 02:26.170
Expand Route Motion modifier and change Warp Target name to Facing Target.

02:26.440 --> 02:32.890
That's the same name we've been using for all of our motion warping targets.

02:32.890 --> 02:35.410
And we're unchecking Warp Translation.

02:35.410 --> 02:39.010
We're only warping rotation and setting rotation type to facing.

02:39.010 --> 02:43.900
And in addition we're going to want a notify that can send an event right.

02:43.900 --> 02:50.380
We're going to right click Add Notify and use our custom A and montage event.

02:50.410 --> 02:53.590
We can select it and choose an event tag.

02:53.830 --> 02:58.570
Now we do have the event montage Firebolt.

02:58.600 --> 03:00.730
We don't have one for electrocute.

03:00.730 --> 03:04.900
So I'd like to add a tag that we can send for electrocute as well.

03:04.900 --> 03:13.210
So I'm going to go to Project Settings into Gameplay tags and take a look at event montage.

03:13.210 --> 03:14.890
Here's Firebolt.

03:15.160 --> 03:16.750
We're going to add one.

03:16.750 --> 03:19.540
So next to montage I'll click plus.

03:19.540 --> 03:22.150
That'll start me off with event montage.

03:22.150 --> 03:24.190
And this will be called electrocute.

03:25.410 --> 03:29.550
Now we'll have an electrocute tag that we can set here.

03:29.580 --> 03:34.560
So now our montage will send an event with the electrocute tag.

03:34.590 --> 03:41.910
So now that we have this montage with it selected in the content browser, we can go back to electrocute

03:41.910 --> 03:44.370
and we can set that montage to this.

03:45.320 --> 03:46.850
And I'm done with project settings.

03:46.850 --> 03:49.990
I'm even done with Cast Electrocute.

03:50.000 --> 03:52.010
I'm going to go ahead and save all.

03:52.190 --> 03:57.050
And now that we have a montage, we can go about playing this montage.

03:57.230 --> 04:04.370
Now, as is the case with Firebolts, we're going to want to update the warp target.

04:04.610 --> 04:12.170
Now we can remind ourselves how we did that by going to Aura Abilities Fire and open a fire bolt.

04:12.260 --> 04:15.380
How are we updating the warp target here?

04:15.380 --> 04:22.280
Well, it looks like we're taking the avatar actor casting to combat interface and calling update facing

04:22.310 --> 04:23.150
target.

04:23.480 --> 04:28.040
Now, I seem to recall that we made this a blueprint native event though, didn't we?

04:28.040 --> 04:32.270
Let's go to Combat Interface and take a look at update facing target.

04:32.270 --> 04:36.740
So we see here that it's a blueprint implementable event blueprint callable.

04:37.070 --> 04:43.670
So if we right click in here and type update facing target here's that interface message.

04:43.790 --> 04:47.240
We can actually pass in an object reference.

04:47.240 --> 04:54.140
We can just get the avatar actor from actor info and pass that in along with the target.

04:54.140 --> 04:56.510
And we have a mouse hit location.

04:59.360 --> 05:07.550
So if we call update facing target and then simply play a montage, then we should be able to see a

05:07.580 --> 05:08.440
turn.

05:08.450 --> 05:09.800
So let's try that.

05:09.830 --> 05:12.260
We'll use play montage and wait.

05:15.220 --> 05:22.570
And we'll plug in electrocute, montage, electrocute, and we'll just see if this works.

05:22.870 --> 05:26.170
So we should see aura play the ability.

05:26.200 --> 05:29.380
Now we can uncheck stop when ability ends.

05:31.950 --> 05:33.510
So she's kind of twitching.

05:33.510 --> 05:39.510
She kind of wants to cast that spell, but let's figure out why it's not working.

05:39.540 --> 05:41.820
Let's go to our montage.

05:41.850 --> 05:47.220
I'm going to set our blend times to a low value 0.01 for blend in.

05:47.610 --> 05:51.510
And we'll go to blend out and set that to 0.01.

05:55.040 --> 05:56.560
Let's see if that helps.

05:58.200 --> 05:59.580
Okay, that's better.

05:59.580 --> 06:04.930
And we see that we're able to get motion warping to work.

06:04.950 --> 06:09.240
Now it looks kind of funny because it's such a fast spell.

06:09.240 --> 06:10.920
You could slow this down.

06:10.950 --> 06:16.950
You could go into the montage and set the rate scale maybe to 0.5.

06:16.950 --> 06:19.260
I'm actually okay with it being fast.

06:20.430 --> 06:23.520
So if you want it slower, you could use that.

06:23.520 --> 06:26.790
But I'd like this to be a fast paced adventure.

06:26.790 --> 06:29.430
So I'd like rate scale to be one.

06:29.430 --> 06:35.190
And now we have our play montage and wait, we're updating the facing target.

06:35.250 --> 06:40.800
We've seen that we don't need to cast to the interface, so we can even go into Firebolt, and we no

06:40.800 --> 06:43.500
longer need to cast to the interface and pass that in.

06:43.500 --> 06:50.790
We could just pass the avatar actor straight in by right clicking and using update facing target, using

06:50.790 --> 06:56.910
the message that takes in a new object rather than the version that takes in the interface itself.

06:56.910 --> 07:00.870
If we do that, we don't need to bother with this cast here.

07:02.160 --> 07:03.630
We can just do this.

07:04.780 --> 07:08.380
So we can test out our Firebolt and make sure that still works.

07:09.170 --> 07:10.760
And of course it does.

07:12.920 --> 07:16.700
So we've simplified this a little bit.

07:16.910 --> 07:18.740
Not a lot, but a little.

07:20.010 --> 07:22.620
Okay, so we're done with Firebolt for now.

07:22.980 --> 07:24.180
I'm going to save all.

07:25.850 --> 07:33.260
An electrocute now plays our electrocute montage, which is really just the start of the electrocute

07:33.260 --> 07:34.040
spell.

07:34.070 --> 07:40.400
Once we start, and as long as we're holding the mouse button down or whatever input is assigned to

07:40.400 --> 07:47.070
this, I'd like to be in the shock loop, which means we're going to want to call that interface function.

07:47.090 --> 07:53.180
Now, it's pretty important that our avatar actor implements the shock interface.

07:53.180 --> 07:55.640
So the first thing we can do is check.

07:57.120 --> 08:01.830
Does implement interface and we can get the avatar actor.

08:04.650 --> 08:10.050
So from the actor info and the interface we're going to check is combat interface.

08:10.800 --> 08:16.590
Now, if we don't implement this interface, there's no point in continuing any further.

08:16.590 --> 08:20.810
So we can go ahead and just place this check straight away.

08:20.820 --> 08:26.370
And in the false case we can just end the ability.

08:30.680 --> 08:35.120
Now this should still work because while we do implement the interface.

08:37.590 --> 08:42.450
And now we know it's safe to access functions and call them on that interface.

08:42.540 --> 08:54.390
So really, this could just be collapsed to a function and we'll say enforce implements combat interface.

08:58.750 --> 09:00.790
That'll keep things a little tidier.

09:01.880 --> 09:07.550
Okay, now that we know we're implementing that interface, for sure, we want to do a couple things

09:07.550 --> 09:12.650
here, like make sure that our characters in the shock loop and.

09:13.610 --> 09:22.580
What I mean is, if we go into blueprints, character aura app aura and take a look at main states,

09:22.610 --> 09:30.140
we have this in shock loop variable and we made a blueprint implementable event for Aura Character to

09:30.140 --> 09:31.070
implement.

09:31.100 --> 09:34.160
So here in the BP for aura character.

09:35.390 --> 09:37.670
Right next to update facing target.

09:37.700 --> 09:39.290
We can also implement.

09:41.380 --> 09:44.080
Set in shock loop.

09:44.730 --> 09:46.140
This is the event.

09:46.560 --> 09:54.060
And what we can do here is set our in loop boolean variable we added in shock loop.

09:54.090 --> 09:55.620
We can now set it.

09:59.440 --> 10:02.740
And our app aura is setting.

10:02.740 --> 10:07.280
It's in shock loop based on the characters in shock Loop here.

10:07.300 --> 10:09.250
So if we set it on aura.

10:10.290 --> 10:12.620
Then our animation blueprint will get it.

10:12.630 --> 10:15.870
Yes, that's a middleman intermediary step.

10:15.900 --> 10:24.630
You could bypass aura and just set it directly on the anim instance if you wanted to do that, but I'm

10:24.630 --> 10:26.240
okay with doing it this way.

10:26.250 --> 10:33.000
So now here in electrocute I want to set that so we can say set in shock loop.

10:33.750 --> 10:37.050
And we made this an interface blueprint callable function.

10:37.050 --> 10:43.290
So as soon as we start playing the montage we can just set this right away because the montage takes

10:43.290 --> 10:48.480
over this state in the animation blueprint here.

10:48.480 --> 10:56.550
So we can set in shock loop and aura will be in this state right here, but we won't see this pose,

10:56.550 --> 11:02.010
will actually see the montage play, and only when the montage is done will be in the shock loop.

11:02.010 --> 11:04.470
So we can set this state right away.

11:04.470 --> 11:06.690
And in fact, we even want to.

11:06.690 --> 11:12.960
Because if we waited till the montage was completed for example, well, that involves a blend in time

11:12.960 --> 11:15.480
and the animation blueprint right here.

11:15.480 --> 11:22.950
And then we'd have to go in and set the blend time here and make sure that we blend right away and things

11:22.950 --> 11:23.370
like that.

11:23.370 --> 11:27.300
But the easiest thing to do is just to set the state right away.

11:27.300 --> 11:33.330
So we have in shock loop there, and we can copy these nodes and we can set in shock loop before we

11:33.330 --> 11:34.830
end the ability as well.

11:34.830 --> 11:36.300
And we'll set that to false.

11:36.300 --> 11:37.620
So now.

11:38.560 --> 11:40.230
If we play test this.

11:41.570 --> 11:44.360
Now, as long as we're holding that mouse button down.

11:45.190 --> 11:49.570
We see aura in the shock loop, and if we release, then she goes back.

11:50.000 --> 11:56.420
And she goes back in a nice, smooth manner because again, the animation blueprint itself will blend

11:56.420 --> 11:57.860
with its own blend settings.

11:57.860 --> 12:05.090
If you want her to go back faster, you can change the duration for this from 0.2 to say 0.1.

12:05.300 --> 12:07.640
She'll go back in a faster manner.

12:09.080 --> 12:09.800
Like that.

12:11.510 --> 12:13.040
I kind of liked 0.2, though.

12:13.070 --> 12:14.780
I think it's nice and smooth.

12:16.060 --> 12:20.260
And again, the montage has its own blend settings too.

12:20.290 --> 12:25.750
So if you wanted the montage to blend in smoother, you could change that blend in time there.

12:25.750 --> 12:32.270
So everything blends when it comes to animations, animation states, and montages in unreal.

12:32.290 --> 12:34.330
So now we're playing the montage.

12:34.360 --> 12:38.890
It looks great, and we're staying in that shock loop as long as we hold our input down.

12:38.890 --> 12:42.340
Now that doesn't matter what input the ability is assigned to.

12:42.370 --> 12:49.060
If we say assign the ability to the one key, for example, then if we press and hold the one key,

12:49.060 --> 12:50.680
then we get the same thing.

12:53.800 --> 12:54.340
Now?

12:54.340 --> 12:54.760
Yes.

12:54.760 --> 13:01.210
If we're moving and we cast the spell, we're interrupted by moving, of course.

13:01.210 --> 13:06.540
So we're going to want to prevent movement while we're in that shock loop.

13:06.550 --> 13:11.740
So for that reason, we're going to want the character movement component so that we can disable movement

13:11.740 --> 13:12.490
on it.

13:12.490 --> 13:19.750
And just like we had an owner player controller, we can have an owner character if we only want to

13:19.750 --> 13:26.950
perform a cast from our avatar actor to a character once, we can just cast once, and because we're

13:26.950 --> 13:30.970
storing the owner player controller, we can do it in this function.

13:30.970 --> 13:35.920
And we could just call this a different name, like store owner variables or something like that.

13:35.920 --> 13:40.150
So just to make this easy, I'm going to go to Aura Beam Spell.

13:40.150 --> 13:42.370
We're going to have a new T object pointer.

13:45.070 --> 13:46.870
This will be an A character.

13:48.050 --> 13:51.980
And we'll call this owning character.

13:53.840 --> 13:56.600
We'll make this also blueprint read, write.

13:56.900 --> 14:02.450
And we'll set this and we'll call this function instead of store owner player controller.

14:02.480 --> 14:05.060
Now we can just call it store owner variables.

14:08.450 --> 14:10.910
And here in the definition.

14:10.940 --> 14:13.000
Now store owner variables.

14:13.010 --> 14:17.720
We can store not only the player controller but our owner character as well.

14:17.720 --> 14:21.530
So what we can do is we can take our owner character.

14:22.070 --> 14:27.530
And in fact we'll do this inside the if check here we'll say owner character.

14:28.750 --> 14:30.160
And it's red.

14:30.160 --> 14:32.810
And that's because I called it owning character.

14:32.830 --> 14:35.560
Let's be consistent and call it owner character.

14:35.680 --> 14:39.280
And I can set this equal to a cast to a character.

14:40.580 --> 14:43.310
And I'll go ahead and cast current actor.

14:43.310 --> 14:44.000
Info.

14:45.690 --> 14:48.330
Dot and we have the avatar actor.

14:48.570 --> 14:50.880
Now we just need to include this type.

14:50.880 --> 14:54.060
And of course character is in game framework.

14:54.060 --> 14:59.940
So we're going to include game framework character dot h.

15:01.890 --> 15:02.910
And that includes it.

15:02.940 --> 15:07.290
Notice that the player controller doesn't have such a requirement.

15:07.320 --> 15:10.350
It's already included implicitly.

15:10.650 --> 15:15.960
So now that we have this owner character and it should be set after store owner variables, then we

15:15.960 --> 15:21.750
should be able to get its movement component and disable movement while we're doing this spell.

15:23.240 --> 15:26.210
So we can go ahead and get our ability back open.

15:26.210 --> 15:32.300
And here in electrocute, let's just go back to this node because it's no longer store owner player

15:32.300 --> 15:33.140
controller.

15:33.170 --> 15:36.950
We're going to replace it with store owner variables instead.

15:38.910 --> 15:41.100
This function does more stuff now.

15:42.000 --> 15:42.870
Okay.

15:42.870 --> 15:49.530
Now, as soon as we're in the shock loop, we should also disable character movement by getting our

15:49.530 --> 15:50.730
owner character.

15:51.210 --> 15:54.750
And by the way, I'm just going to hit compile to get rid of those errors.

15:55.020 --> 15:56.670
So I'm going to get owner character.

15:57.810 --> 16:01.260
It's a character type, so we can get character movement.

16:01.440 --> 16:03.290
The movement component.

16:03.300 --> 16:06.570
And from that we can call disable movement.

16:08.350 --> 16:09.280
Like so.

16:09.280 --> 16:12.230
And if we disable movement, we won't be able to move.

16:12.250 --> 16:16.750
But we got to remember to re enable movement later, right?

16:17.610 --> 16:19.200
So how do we do that?

16:19.230 --> 16:23.970
Well, the character movement component doesn't have a function called enable movement.

16:24.740 --> 16:28.580
What it has is set movement mode.

16:29.810 --> 16:33.830
And we can set it to walking and that's going to enable movement again.

16:34.400 --> 16:40.880
So before we do that, let's just see how this works with disabling movement without enabling it back.

16:42.070 --> 16:43.510
And let's try to move around.

16:43.510 --> 16:47.470
I'm trying to actually do the wasD thing.

16:51.340 --> 16:52.570
And I can't.

16:52.870 --> 16:54.880
And before I cast the spell.

16:56.570 --> 17:01.710
I can use to move as soon as I start the spell.

17:01.730 --> 17:02.570
I can't.

17:03.610 --> 17:06.250
Now notice motion warping doesn't work either.

17:06.250 --> 17:08.050
We've completely disabled movement.

17:08.050 --> 17:14.680
That includes root motion movement from motion warping, so we'll have to disable movement at a later

17:14.680 --> 17:15.340
time.

17:15.870 --> 17:24.090
But as soon as we are about to end the ability, let's get our character movement component and set

17:24.120 --> 17:25.290
movement mode.

17:26.690 --> 17:27.740
Two walking.

17:33.390 --> 17:36.030
So I can move around with wasD.

17:36.690 --> 17:38.910
I can right click and hold.

17:39.070 --> 17:43.020
Can't move and if I release I can move again.

17:43.020 --> 17:46.680
So setting that movement mode back to walking enables it.

17:46.680 --> 17:54.380
The problem is that we don't get that motion warping if we disable movement before we motion warp.

17:54.390 --> 17:56.090
So what's the easiest way to do?

17:56.100 --> 18:00.990
When is the best place to disable movement?

18:01.020 --> 18:05.280
Well, I don't want to do it when completed or blended out or anything like that.

18:05.280 --> 18:11.610
What I'd rather do is wait for a gameplay event, and as soon as we get that gameplay event, which

18:11.610 --> 18:16.200
we know we're sending from the montage, we can then respond to it.

18:16.200 --> 18:22.980
So I'm going to call wait gameplay event and use the ability task.

18:24.150 --> 18:25.350
And we'll do this right away.

18:25.350 --> 18:27.240
We're not going to use any of these.

18:28.240 --> 18:32.350
And as soon as an event is received, we'll hook this up to event received.

18:33.240 --> 18:42.090
Then we can disable movement and be in shock loop and the event tag is going to be event dot montage,

18:42.090 --> 18:43.590
dot electrocute.

18:43.650 --> 18:45.990
And we only want to trigger once.

18:47.080 --> 18:47.950
There we go.

18:50.520 --> 18:52.770
So now this should work.

18:54.760 --> 19:03.280
We can run around, we can shock and we can run around and motion warping works.

19:09.840 --> 19:10.710
Perfect.

19:11.010 --> 19:14.190
Now that's taking care of the animation side of things.

19:14.190 --> 19:21.000
And to keep this blueprint under control, we're going to want to make sure things are nice and tidy

19:21.030 --> 19:22.640
as much as we can.

19:22.650 --> 19:29.790
So we know that if we're beginning our shock loop, we're going to want to disable movement, right?

19:29.790 --> 19:36.810
And before we end the ability, we're going to want to prepare to end the ability by showing the mouse

19:36.810 --> 19:42.600
cursor again setting in shock loop to false, setting the movement mode back right.

19:42.600 --> 19:45.870
So this is all stuff that should happen at the end of the ability.

19:45.960 --> 19:48.660
So we can collapse this all to a node.

19:48.690 --> 19:51.000
Right click collapse the function.

19:51.000 --> 19:54.960
And we can call this prepare to end ability.

19:57.250 --> 20:01.180
And that's going to take care of the things that need to happen.

20:01.740 --> 20:08.820
When we're about to end the ability and then setting the in shock loop and disabling movement.

20:08.850 --> 20:12.070
This is all stuff we're handling for the shock loop.

20:12.090 --> 20:16.680
So we're just going to call this one collapse the function.

20:18.780 --> 20:20.100
In shock loop.

20:24.200 --> 20:31.940
So we're setting those variables there and updating the facing target and showing the mouse cursor.

20:32.670 --> 20:34.920
Those are actually two different things.

20:34.920 --> 20:37.350
So we can have update facing target.

20:37.350 --> 20:42.570
We can collapse that to a function and I'll just call it update facing target.

20:45.840 --> 20:49.560
And then this one can just be showing the mouse cursor.

20:49.560 --> 20:54.510
In fact, we could even have a function that takes in a boolean.

20:55.870 --> 21:00.770
Or if you don't mind having two nodes, it might be overkill to refactor.

21:00.790 --> 21:03.820
So I think so far that's okay.

21:06.700 --> 21:10.930
Okay, so now we have our animations working for electrocute.

21:10.960 --> 21:12.610
Things are looking pretty good.

21:12.670 --> 21:18.370
Now we need to start working on other things, such as spawning the beam particles and such.

21:18.400 --> 21:22.750
So we'll get the rest of this implemented in the videos to come.

21:22.870 --> 21:23.860
I'll see you soon.
