WEBVTT

00:01.030 --> 00:01.570
All right.

00:01.570 --> 00:02.740
I got a fun one for you.

00:02.740 --> 00:06.700
This time, I'd like you to make some timelines for our fireball.

00:06.700 --> 00:08.860
So create some timelines.

00:08.860 --> 00:11.020
Maybe one, maybe two.

00:11.020 --> 00:15.640
And I'd like you to make our fireballs fly out and then back in.

00:15.640 --> 00:21.640
So they're going to fly out for a certain distance, at which point they slow down and come back to

00:21.640 --> 00:22.180
aura.

00:22.180 --> 00:27.940
And I'd like you to control their positions directly using values from the timeline.

00:27.940 --> 00:35.050
And I'd also like you to make the fireballs come back to aura, and not just back to their initial launch

00:35.050 --> 00:36.040
location.

00:36.310 --> 00:42.610
That means if aura is running around, then those fireballs are going to probably need to adjust as

00:42.610 --> 00:43.690
they're coming back.

00:43.690 --> 00:46.270
So that's a little bit more of a challenge.

00:46.270 --> 00:52.600
It's a little harder doing this than it is to make the fireballs go back to their initial launch position.

00:52.600 --> 00:57.550
So take that into account, pause the video and conquer this quest now.

01:01.740 --> 01:02.340
Okay.

01:02.340 --> 01:05.850
So I'm going to make some timelines in our fireball blueprint.

01:05.850 --> 01:12.180
But before we do that I'd like to make a function in C plus plus a blueprint callable one that we can

01:12.180 --> 01:13.890
call to start the timeline.

01:13.890 --> 01:20.100
And for that reason I'm going to close down the editor first and go into Aura Fireball.

01:21.350 --> 01:23.090
And make a function.

01:23.090 --> 01:24.560
We can make this public.

01:24.560 --> 01:29.960
It's going to be called void start outgoing timeline.

01:31.420 --> 01:33.520
And I'm going to implement this in blueprint.

01:33.520 --> 01:38.290
So I'm going to make it a new function with blueprint implementable event.

01:38.620 --> 01:40.990
So I don't need to implement it here.

01:40.990 --> 01:44.710
In addition though, there's another thing that I want to expose to blueprint.

01:44.710 --> 01:52.540
And that's an aura projectile we have on hit and on hit is handling, playing a sound, spawning a particle

01:52.540 --> 01:56.890
system, and stopping the looping sound and setting a boolean to true.

01:56.890 --> 02:01.180
This is basically doing everything except for destroy our projectile.

02:01.180 --> 02:03.970
This would be useful to expose to blueprint as well.

02:03.970 --> 02:06.670
So I'm going to make this one blueprint callable.

02:07.390 --> 02:12.310
So give it a new function blueprint callable perfect.

02:12.310 --> 02:20.440
And before launching back up I'm going to go into Aura Fireball and just go into begin play and call

02:20.440 --> 02:24.910
my start outgoing timeline blueprint implementable event.

02:24.910 --> 02:26.590
Just so we started.

02:26.590 --> 02:31.120
And with that we can go ahead and launch the editor.

02:32.890 --> 02:36.910
Okay, so I need to get my fireball open here.

02:36.910 --> 02:40.210
And I need to implement start outgoing timeline.

02:42.040 --> 02:43.570
So here's my event.

02:44.000 --> 02:49.220
And I'd only like to control the location of this fireball on the server.

02:49.220 --> 02:50.450
So first things first.

02:50.450 --> 02:58.760
I'm going to check has authority and switch on that and only do anything if I have authority.

02:58.760 --> 03:01.250
So what are we going to do if we have authority?

03:01.250 --> 03:06.320
Well, I'm going to make a timeline to control my outgoing position.

03:06.320 --> 03:09.530
So I'm going to make a timeline here.

03:11.200 --> 03:13.810
And I'm going to call this outgoing timeline.

03:16.790 --> 03:24.350
So outgoing timeline is going to get a float track and I'm going to call this outgoing track.

03:25.520 --> 03:29.600
An outgoing track can have two points on it, two keys.

03:29.600 --> 03:31.370
So I'm going to add two of them.

03:32.270 --> 03:36.410
And how long do I want these fireballs flying out?

03:36.410 --> 03:41.120
Well, I'm going to make it about one second long, so I'm going to set the length of my timeline to

03:41.120 --> 03:45.290
one and set the first key at time zero.

03:46.050 --> 03:52.620
With a value of zero, and the second key will be at time one with a value of one.

03:53.990 --> 03:56.540
So this will be a normalized curve.

03:56.540 --> 04:03.230
It's going to be something we use along with a maximum distance that we want our fireballs to travel.

04:03.470 --> 04:07.040
I'm going to make it an auto curve and I'm going to shape it like this.

04:07.600 --> 04:14.590
Because I want my fireballs to go out really fast with a high speed and taper off, and then slowly

04:14.590 --> 04:15.100
come back.

04:15.100 --> 04:17.530
Now we're not focused on coming back just yet.

04:17.530 --> 04:19.210
This is just going out.

04:19.690 --> 04:22.330
And how am I going to do this?

04:22.330 --> 04:25.810
Well, I'm going to set actor location somehow.

04:25.810 --> 04:28.360
So if I call set actor location.

04:29.530 --> 04:34.240
We need some location to set in our update, right?

04:34.270 --> 04:37.540
Well, what I'd like to do for my location is.

04:37.540 --> 04:41.260
For one, I need a location to pass in.

04:41.260 --> 04:48.490
So before we start the timeline, I'm going to calculate a location for my target.

04:48.490 --> 04:51.970
At the end of the timeline, I'm going to call it the apex.

04:52.000 --> 04:59.740
Apex generally refers to the highest point in an object's flying trajectory, but I'm referring to the

04:59.740 --> 05:02.260
farthest point out as the apex.

05:02.260 --> 05:07.030
So I'm going to calculate my initial location and my apex location.

05:07.030 --> 05:09.070
So I have a start and an end.

05:09.850 --> 05:14.830
So the start is going to be my current location at the time the timeline started.

05:14.830 --> 05:17.260
So I'm going to call Get Actor location.

05:19.210 --> 05:20.380
And I'm going to store this.

05:20.380 --> 05:24.340
I'm going to promote it to a variable and call it initial location.

05:26.630 --> 05:29.300
Now I also need my apex location.

05:29.330 --> 05:30.860
How am I going to calculate that?

05:30.860 --> 05:34.040
Well, let's get these three nodes here out of the way.

05:34.040 --> 05:37.220
I'm going to take my forward vector.

05:37.490 --> 05:39.830
So get actor forward vector.

05:41.180 --> 05:45.200
And I'm going to multiply this actor forward vector which should be a unit vector.

05:45.200 --> 05:49.820
By the way I'm going to multiply it by a float to scale it out.

05:50.640 --> 05:54.780
Because I want it to be as long as my travel distance.

05:54.780 --> 06:00.420
So I'm going to right click on this second pin, convert it to a float single precision and promote

06:00.420 --> 06:04.170
this to a variable and call this travel distance.

06:06.280 --> 06:11.650
And I can compile and give travel distance a default value if I like.

06:11.950 --> 06:17.470
I'm just going to pick a number, say 1600, but we can tweak that value of course.

06:17.470 --> 06:24.970
But now that I have this vector, I can add this to my initial location and that will give me my apex

06:24.970 --> 06:25.810
location.

06:25.810 --> 06:34.630
So if I take my initial location and I add and I add this vector which points out in the forward direction,

06:34.630 --> 06:40.810
but it's scaled by travel distance, this gives me my apex location, and that's what I'm going to call

06:40.810 --> 06:42.670
it apex location.

06:42.670 --> 06:46.270
So now I have an initial and a destination.

06:46.540 --> 06:52.270
And what I can do is use my outgoing track, which goes from 0 to 1, and I can lerp.

06:52.300 --> 06:54.940
Lerp is a linear interpolation.

06:56.210 --> 07:05.000
If I take my initial location and I drag off and type lerp, I can lerp vector passing in initial location

07:05.000 --> 07:09.680
for a apex, location for B and an alpha.

07:09.710 --> 07:18.020
Now what we get out of this node is a vector between these two, depending on the alpha.

07:18.020 --> 07:22.970
If the alpha is zero, the return value is going to be a initial location.

07:22.970 --> 07:28.400
If the alpha is one, the return value is going to be B apex location.

07:28.520 --> 07:35.240
And if it's say 0.5, then we would get the vector in between these two it's linearly interpolating.

07:35.420 --> 07:43.130
Well I can pass outgoing track into this lerp and take the lerp and pass it into set actor location.

07:43.610 --> 07:51.530
And this allows me to set the location starting at initial going to apex, and will be smoothly going

07:51.530 --> 07:54.050
to it according to our curve.

07:54.050 --> 07:56.240
Let's go ahead and hook this up.

07:56.240 --> 08:00.140
I'm going to just hook up play and I want to see what this looks like.

08:00.140 --> 08:00.500
Now.

08:00.500 --> 08:04.430
First I need to get my projectile movement component and disable it.

08:04.430 --> 08:04.970
Again.

08:04.970 --> 08:09.680
I'm going to go ahead and just put a zero in for initial speed and max speed.

08:09.680 --> 08:15.800
Scroll down and disable everything from auto activate to wears.

08:15.800 --> 08:16.790
Start with tick enabled.

08:16.790 --> 08:17.720
There it is.

08:17.720 --> 08:21.710
And with that we now no longer have projectile movement.

08:21.710 --> 08:24.020
We're now controlling our movement here.

08:24.020 --> 08:25.220
Let's see how it works.

08:25.220 --> 08:28.430
I'm going to go ahead press play and hit the two key.

08:29.290 --> 08:30.130
And there they go.

08:30.130 --> 08:33.040
And they slow to a stop right there.

08:33.070 --> 08:34.450
Pretty fascinating.

08:34.450 --> 08:34.780
Right.

08:34.780 --> 08:36.760
And we can change that travel distance.

08:36.760 --> 08:43.330
That's the magic of having these member variables like this is if I change travel distance to 400,

08:43.330 --> 08:44.830
I accidentally hit four twice.

08:44.830 --> 08:46.330
I'm just going to leave it at 440.

08:46.330 --> 08:47.710
Let's see what it looks like.

08:49.140 --> 08:57.750
So over the space of a second, our projectiles fly out fast at first, but they slow to a stop, right?

08:59.630 --> 09:05.840
So that takes care of the outgoing timeline, but I'm going to want them to come back in as well.

09:06.420 --> 09:11.280
So before we do that, let's put some comments on this section here.

09:11.280 --> 09:16.920
We're going to say store initial and Apex locations.

09:16.920 --> 09:20.250
And this has a lot to do with vectors a lot of yellow.

09:20.250 --> 09:22.440
So I'm going to make this a yellow comment.

09:22.860 --> 09:29.160
And then after we've done this part a very important part here.

09:31.540 --> 09:32.740
And I'll move this.

09:33.740 --> 09:37.880
Let's see if we can overlap as little as possible here.

09:40.800 --> 09:42.210
With our wires.

09:43.470 --> 09:51.630
After this, our timeline is going to execute finished when it's done right and when finished, I'd

09:51.630 --> 09:56.160
like to execute another timeline, one for coming back in.

09:56.160 --> 09:58.830
So I'm going to right click and type timeline.

10:00.180 --> 10:04.380
Scroll all the way to the bottom and add a new timeline and call this one.

10:04.530 --> 10:08.820
Returning or incoming either one returning timeline.

10:09.420 --> 10:15.000
And as soon as Outgoing Timeline is finished, we're going to play the returning timeline, and this

10:15.000 --> 10:21.780
one is going to get a track of its own a float track called Returning Track.

10:23.330 --> 10:26.330
And just like outgoing track, it's going to get two keys.

10:26.330 --> 10:27.620
One, two.

10:27.650 --> 10:33.080
The first one will be at time zero and it'll have a value of zero.

10:33.110 --> 10:39.170
The second is going to get a time of one and it'll have a value of one.

10:39.560 --> 10:44.570
And I can go ahead and normalize it and set the length of the track to one.

10:44.990 --> 10:47.900
So why bother creating a whole timeline for this?

10:47.900 --> 10:50.510
Well we can make this a different shape.

10:50.510 --> 10:58.760
I'm going to make this an auto curve and shape it by grabbing the last key point and put it like this.

11:00.640 --> 11:03.910
So the first curve looks like this.

11:03.910 --> 11:07.540
We're starting off fast and slowing down.

11:07.540 --> 11:10.420
The returning timeline curve starts like this.

11:10.450 --> 11:13.810
It starts off slow and then gets faster.

11:15.500 --> 11:19.370
So with our returning timeline, let's go back to our event graph.

11:19.370 --> 11:23.810
We have our returning track and let's decide how we're going to do this.

11:23.810 --> 11:29.540
I know for sure I'm going to be using set actor location, so I'm going to go ahead and hook that up

11:29.540 --> 11:30.650
to update.

11:31.240 --> 11:33.820
But how am I going to lerp this one?

11:33.820 --> 11:35.980
Well, I can duplicate lerp.

11:37.720 --> 11:41.680
And we're starting off at the apex location this time.

11:41.680 --> 11:44.710
So that's going to be a but what's B?

11:44.740 --> 11:49.870
Well, B needs to be the actor that we're returning back to.

11:50.140 --> 11:53.080
So how do we know what that actor is.

11:53.110 --> 11:55.480
Well we're going to have to set it somehow.

11:55.570 --> 12:00.970
So I'd like to add a variable to our fireball that we can set when we spawn it.

12:00.970 --> 12:01.750
Let's do that.

12:01.750 --> 12:03.940
Let's go ahead and close the editor down.

12:03.940 --> 12:09.010
We'll save all and we'll go back to our fireball and we'll add an actor.

12:09.010 --> 12:13.960
So it's going to be a public variable just so we can set it from outside the class.

12:13.960 --> 12:16.180
Let's make it a t object pointer.

12:16.930 --> 12:18.970
And this will be an A actor.

12:19.330 --> 12:22.870
And we're going to call this return to actor.

12:23.230 --> 12:27.820
And we'll give it a U property and make it blueprint read only.

12:28.030 --> 12:30.640
And we'll set this as soon as we spawn it.

12:30.640 --> 12:33.040
So we'll go back to Aura Fire Blast.

12:33.040 --> 12:38.020
And as soon as we've spawned the fireball, we're setting its damage effect params.

12:38.020 --> 12:39.730
We're also going to set.

12:40.850 --> 12:42.830
Its return to actor.

12:43.040 --> 12:44.990
And what are we going to return to?

12:44.990 --> 12:46.130
Well that's easy.

12:46.640 --> 12:50.480
Get avatar actor from actor info.

12:50.840 --> 12:53.840
And with that, we now have a valid return to actor.

12:53.840 --> 12:55.550
We've exposed it to blueprint.

12:55.820 --> 12:58.820
Now we can use it in our event graph.

13:00.490 --> 13:01.150
Okay.

13:01.150 --> 13:03.100
So we're going to go ahead and open.

13:03.550 --> 13:11.080
And now in our lerp we can use Return to actor and we can get its actor location.

13:12.270 --> 13:13.980
With Get Actor location.

13:14.620 --> 13:19.180
We can hook that in for B and our track is going to go into Alpha.

13:26.100 --> 13:28.140
So we can bring this up here.

13:35.490 --> 13:38.100
I'm just tidying things up a bit.

13:38.820 --> 13:41.340
And this will go into new location.

13:41.700 --> 13:42.840
Now here's the thing.

13:42.840 --> 13:45.600
As soon as we're done, I want to blow up.

13:47.140 --> 13:55.600
So I'm going to place a branch right here after we've set the active location and blow up under a certain

13:55.600 --> 13:56.110
condition.

13:56.110 --> 13:57.730
Now, what is that condition?

13:57.730 --> 14:04.450
Well, I want a specific distance that these should blow up as soon as they come back within that distance.

14:04.450 --> 14:09.520
So I'm going to add a new variable and call this explode distance.

14:10.060 --> 14:11.650
It's going to be a float.

14:11.800 --> 14:14.380
I can compile and give it a value.

14:15.190 --> 14:18.550
And I'll just make it say 250.

14:18.550 --> 14:24.670
So when our fireballs are coming back, as soon as they're close enough, close enough.

14:24.670 --> 14:28.150
Being 250 away, we're going to blow up.

14:28.150 --> 14:30.850
So let's check that distance.

14:31.430 --> 14:35.420
So first of all, we need to check the distance between this fireball.

14:36.560 --> 14:39.200
That's get actor location

14:41.000 --> 14:42.260
minus.

14:42.870 --> 14:44.190
Minus what?

14:44.220 --> 14:48.030
Minus the location of return to actor.

14:51.080 --> 14:54.020
And after we have this vector, we get its length.

14:54.140 --> 14:56.720
So we use vector length.

14:58.010 --> 14:59.090
And we check this length.

14:59.090 --> 15:02.390
We say, is this less than or equal to?

15:03.540 --> 15:06.000
And we have our explode distance.

15:07.180 --> 15:11.740
This can go into our branch and this could be a blueprint, pure function.

15:11.740 --> 15:12.880
We can collapse.

15:12.880 --> 15:19.660
The function we can call this is within explode distance.

15:20.170 --> 15:25.600
And we can take this function and make it a blueprint pure by checking pure like that.

15:27.700 --> 15:29.140
So that looks nice.

15:30.240 --> 15:35.040
So if we should explode, if is within explode distance.

15:35.040 --> 15:37.140
Well, we have on hit, don't we?

15:40.130 --> 15:43.280
That's going to do lots of things for us.

15:43.280 --> 15:46.550
It's going to make our explosion happen.

15:48.190 --> 15:50.530
Now all of this happens on the server.

15:50.530 --> 15:55.360
So if on hit happens then we can just destroy actor.

15:57.270 --> 16:01.110
Let's see how this all works with our incoming timeline.

16:01.860 --> 16:05.400
I'm going to save all first and press the two key.

16:06.690 --> 16:09.390
And that looks amazing.

16:12.520 --> 16:17.500
And the cool thing is, if we're running around, it looks even better because check this out.

16:18.550 --> 16:19.450
Boom.

16:24.480 --> 16:25.650
That looks so good.

16:25.650 --> 16:32.100
Now I would like to change the travel distance because 440 is a little low.

16:32.130 --> 16:33.840
I'm going to try 800.

16:35.580 --> 16:37.530
I might even have it even more than that.

16:37.530 --> 16:37.830
Oops.

16:37.830 --> 16:39.210
Wrong spell.

16:39.390 --> 16:40.680
That's the one.

16:41.920 --> 16:46.960
Look at that and the explode distance is a little high, I think.

16:46.960 --> 16:54.580
So I'm going to go ahead and change the explode distance from 250 to let's try 150.

16:58.860 --> 17:00.150
I like it.

17:01.320 --> 17:04.080
Now things are looking good visually.

17:04.840 --> 17:06.670
But we don't cause any damage.

17:06.670 --> 17:12.760
We'll see that they can pass through enemies, these fireballs, and they can even explode next to them.

17:12.760 --> 17:14.470
Nothing really happens.

17:14.470 --> 17:17.920
So we're going to need to make these fireballs functional.

17:17.920 --> 17:20.530
But visually, this is looking pretty.

17:20.530 --> 17:21.700
Pretty nice.

17:24.940 --> 17:29.260
So awesome if you got through this whole challenge, congratulations!

17:29.260 --> 17:30.670
I'm really proud of you.

17:30.670 --> 17:32.380
And if not, don't worry about it.

17:32.380 --> 17:34.090
We got fireballs now.

17:34.120 --> 17:39.100
Things are looking great and we'll continue in the next video.
