WEBVTT

00:00.050 --> 00:00.440
Hello guys.

00:00.440 --> 00:01.310
Welcome to the video.

00:01.310 --> 00:05.150
So this is going to be clean up and wrap up for this section.

00:05.150 --> 00:06.770
We did a lot of work.

00:06.770 --> 00:08.390
I think we did a pretty good job.

00:08.390 --> 00:11.450
We did set up a bunch of mechanics that we can use on the levels.

00:11.450 --> 00:16.580
And there are some things that I skipped, but it's only because I think we did enough with the traps

00:16.580 --> 00:22.400
and we need to move on to the enemies UI sounds, because if you do the same thing for a while, it

00:22.400 --> 00:24.680
can get tiresome and pretty boring, I would say.

00:24.680 --> 00:27.650
And I want to, you know, keep going with the development.

00:27.650 --> 00:32.420
Uh, so we did arrow, we did volume platform fire.

00:32.810 --> 00:34.670
This is just a platform.

00:34.670 --> 00:36.260
Nothing special.

00:36.500 --> 00:37.640
This one we didn't do.

00:37.640 --> 00:43.040
It seems interesting to me, but also I'm not sure if we really need it because I don't like the idea

00:43.040 --> 00:43.550
of itself.

00:43.550 --> 00:47.720
It's basically like an enemy, but we're going to have a bunch of enemies, so I don't know, why would

00:47.720 --> 00:48.650
we need this one?

00:49.220 --> 00:49.820
And we did.

00:49.820 --> 00:54.260
So spiked ball spikes, trampoline, so many cool things.

00:54.260 --> 00:55.340
I like it a lot.

00:55.340 --> 00:56.060
Yeah.

00:56.570 --> 01:03.140
Now what I'm going to do here is something nice before we finish this section on a trap.

01:03.140 --> 01:03.710
So.

01:04.530 --> 01:06.750
We dig in waypoints to move the object.

01:06.750 --> 01:13.020
And I'm afraid it may happen that you make another waypoint and you forget to add it to the script.

01:13.020 --> 01:14.970
So this is what I want to do.

01:15.450 --> 01:19.050
Uh, first let's go to traps and make.

01:20.070 --> 01:22.350
C sharp script trap.

01:23.340 --> 01:29.220
So we point and we're going to select waypoints.

01:30.380 --> 01:31.730
That we have.

01:31.730 --> 01:32.750
Let me delete the extra.

01:32.750 --> 01:36.800
Let's select this waypoints and put it on the object.

01:36.800 --> 01:41.360
So now these objects have a component of a Trapsoul waypoint.

01:41.950 --> 01:46.030
And I think I just will clean it up like so.

01:46.030 --> 01:47.650
I don't need anything here.

01:48.040 --> 01:50.410
Just that now I'm going to save it.

01:50.410 --> 01:52.060
I'm going to go to Trapsoul.

01:52.600 --> 01:55.360
And when we updating waypoints info.

01:55.360 --> 01:57.610
What I want to do here is to make a list.

01:57.640 --> 02:03.610
List is basically like an array, but the difference is that list can be changed dynamically.

02:03.610 --> 02:08.920
You can remove or add elements in the script in the start or during the game itself.

02:08.920 --> 02:13.930
And I want to use list of waypoints just like that.

02:13.930 --> 02:17.530
And it's going to be equals to new list of waypoints.

02:17.530 --> 02:27.520
And in the parentheses we're going to type get components in children with a plural of list trap waypoint

02:27.850 --> 02:29.440
of trap waypoint.

02:32.060 --> 02:32.900
Nice.

02:32.900 --> 02:33.980
What is it?

02:36.820 --> 02:40.480
All we need to give it a name waypoint list.

02:40.480 --> 02:41.680
So what it does.

02:41.680 --> 02:43.600
I know it's super confusing here.

02:43.600 --> 02:52.450
It makes a new list as a local variable, and it makes it equals to the new list, which is filled with

02:52.450 --> 02:56.590
the objects that we get as a components in children.

02:56.590 --> 02:59.320
Basically this one it does.

02:59.320 --> 03:06.820
And just to explain why we need it, we can go and just do debug log waypoint list dot count.

03:06.820 --> 03:08.530
Let's see how many we collect.

03:10.360 --> 03:13.690
And over here I'm going to duplicate one.

03:15.620 --> 03:17.540
Like so and go to play mode.

03:20.050 --> 03:22.150
And we can see we have message four.

03:22.150 --> 03:24.340
We've got four waypoints.

03:26.710 --> 03:31.000
This will help us to check how many waypoints we have under the trap.

03:31.000 --> 03:37.030
So then we can go ahead over here and compare the lengths.

03:39.430 --> 03:41.170
Of the waypoints and do this.

03:41.170 --> 03:50.740
If waypoint list dot count is not equals to waypoint dot length means we forgot to assign some of the

03:50.740 --> 03:59.560
waypoints into the list in the inspector over here, and if that's the case, then we can do waypoint.

04:00.910 --> 04:06.430
Equals to new transform array with a waypoint list count.

04:06.430 --> 04:14.380
And then we will do for loop with a waypoint list count and we will do waypoint I is equals to waypoint

04:14.380 --> 04:18.340
list I dot transform just like that.

04:18.340 --> 04:18.730
Yeah.

04:18.730 --> 04:19.660
What are we doing here?

04:19.660 --> 04:24.790
Maybe it's a bit confusing because I had to think while I'm typing we make it an empty list.

04:25.060 --> 04:32.290
A new list in the method as a local variable, and we're collecting all of the children of a these gameobjects

04:32.290 --> 04:33.730
that having a trap.

04:33.730 --> 04:35.860
So waypoint component.

04:35.860 --> 04:38.650
So now we have a list of waypoint components.

04:38.650 --> 04:44.110
Then we check if count of this list is not equals to the waypoint length that we have in the inspector

04:44.110 --> 04:49.570
over here means we have more children that we assigned in the waypoint list over here.

04:50.080 --> 04:57.250
And if that's the case then we take waypoint array and making it equals to new empty array with the

04:57.250 --> 04:59.320
length of a waypoint list count.

04:59.320 --> 05:05.170
Then we take in a for loop that runs the same amount of time as elements we have in our waypoint list,

05:05.170 --> 05:08.740
and making each I equals to the element from the list.

05:08.980 --> 05:15.820
And now because of that, we will collect all of the objects and put them into the array just like that.

05:15.820 --> 05:18.550
This basically will automate the process.

05:18.550 --> 05:21.010
And now we can go back to unity.

05:21.490 --> 05:24.610
And let's say you want to extend the travel of the.

05:24.610 --> 05:27.940
So just by adding more waypoints like.

05:28.990 --> 05:31.180
That, for example.

05:31.180 --> 05:31.870
Why not?

05:31.870 --> 05:33.070
Yeah, seven of them.

05:33.070 --> 05:37.840
And it would be a headache to assign them into array again, especially if you have a bunch of things

05:37.840 --> 05:39.430
to set up on different levels.

05:39.430 --> 05:42.010
So now we can just go to play mode.

05:43.780 --> 05:50.710
And it will be automatically collected into the waypoint array and then automatically given to the Vector3

05:50.890 --> 05:52.210
array with the positions.

05:52.210 --> 05:55.960
And now Trapsaw is travelling just like that.

05:59.790 --> 06:00.720
You see the point?

06:00.780 --> 06:01.500
Yeah.

06:01.530 --> 06:02.100
Nice.

06:02.100 --> 06:03.870
If you decide to delete some.

06:05.340 --> 06:06.090
I'd say delete some.

06:06.090 --> 06:07.020
Now you have less.

06:07.020 --> 06:11.460
You don't have to adjust array again because you can just go to play mode.

06:13.310 --> 06:14.360
And.

06:14.970 --> 06:17.070
It will take all of the elements you have.

06:17.100 --> 06:22.860
I'm still going to keep this variable open and visible so we can see how it's working.

06:22.950 --> 06:25.170
But other than that, we're good.

06:25.200 --> 06:27.180
This is just brilliant, I think.

06:27.600 --> 06:28.530
All right.

06:28.530 --> 06:29.430
This is good.

06:29.430 --> 06:31.980
Now let me apply override.

06:32.770 --> 06:33.610
And.

06:34.890 --> 06:38.280
Regarding other scripts, I was pretty careful, so I think it's fine.

06:38.280 --> 06:42.420
I'm just going to quickly check everything and then we're going to wrap this up and that's going to

06:42.420 --> 06:43.740
be good for this section.

06:44.250 --> 06:45.870
Yeah I think it's all super good.

06:45.870 --> 06:47.700
Thank you so much for paying attention guys.

06:47.700 --> 06:49.080
Let's go to the next section.

06:49.080 --> 06:50.700
We're going to work with enemies.
