Hello guys.
Welcome to the video.
So this is going to be clean up and wrap up for this section.
We did a lot of work.
I think we did a pretty good job.
We did set up a bunch of mechanics that we can use on the levels.
And there are some things that I skipped, but it's only because I think we did enough with the traps
and we need to move on to the enemies UI sounds, because if you do the same thing for a while, it
can get tiresome and pretty boring, I would say.
And I want to, you know, keep going with the development.
Uh, so we did arrow, we did volume platform fire.
This is just a platform.
Nothing special.
This one we didn't do.
It seems interesting to me, but also I'm not sure if we really need it because I don't like the idea
of itself.
It's basically like an enemy, but we're going to have a bunch of enemies, so I don't know, why would
we need this one?
And we did.
So spiked ball spikes, trampoline, so many cool things.
I like it a lot.
Yeah.
Now what I'm going to do here is something nice before we finish this section on a trap.
So.
We dig in waypoints to move the object.
And I'm afraid it may happen that you make another waypoint and you forget to add it to the script.
So this is what I want to do.
Uh, first let's go to traps and make.
C sharp script trap.
So we point and we're going to select waypoints.
That we have.
Let me delete the extra.
Let's select this waypoints and put it on the object.
So now these objects have a component of a Trapsoul waypoint.
And I think I just will clean it up like so.
I don't need anything here.
Just that now I'm going to save it.
I'm going to go to Trapsoul.
And when we updating waypoints info.
What I want to do here is to make a list.
List is basically like an array, but the difference is that list can be changed dynamically.
You can remove or add elements in the script in the start or during the game itself.
And I want to use list of waypoints just like that.
And it's going to be equals to new list of waypoints.
And in the parentheses we're going to type get components in children with a plural of list trap waypoint
of trap waypoint.
Nice.
What is it?
All we need to give it a name waypoint list.
So what it does.
I know it's super confusing here.
It makes a new list as a local variable, and it makes it equals to the new list, which is filled with
the objects that we get as a components in children.
Basically this one it does.
And just to explain why we need it, we can go and just do debug log waypoint list dot count.
Let's see how many we collect.
And over here I'm going to duplicate one.
Like so and go to play mode.
And we can see we have message four.
We've got four waypoints.
This will help us to check how many waypoints we have under the trap.
So then we can go ahead over here and compare the lengths.
Of the waypoints and do this.
If waypoint list dot count is not equals to waypoint dot length means we forgot to assign some of the
waypoints into the list in the inspector over here, and if that's the case, then we can do waypoint.
Equals to new transform array with a waypoint list count.
And then we will do for loop with a waypoint list count and we will do waypoint I is equals to waypoint
list I dot transform just like that.
Yeah.
What are we doing here?
Maybe it's a bit confusing because I had to think while I'm typing we make it an empty list.
A new list in the method as a local variable, and we're collecting all of the children of a these gameobjects
that having a trap.
So waypoint component.
So now we have a list of waypoint components.
Then we check if count of this list is not equals to the waypoint length that we have in the inspector
over here means we have more children that we assigned in the waypoint list over here.
And if that's the case then we take waypoint array and making it equals to new empty array with the
length of a waypoint list count.
Then we take in a for loop that runs the same amount of time as elements we have in our waypoint list,
and making each I equals to the element from the list.
And now because of that, we will collect all of the objects and put them into the array just like that.
This basically will automate the process.
And now we can go back to unity.
And let's say you want to extend the travel of the.
So just by adding more waypoints like.
That, for example.
Why not?
Yeah, seven of them.
And it would be a headache to assign them into array again, especially if you have a bunch of things
to set up on different levels.
So now we can just go to play mode.
And it will be automatically collected into the waypoint array and then automatically given to the Vector3
array with the positions.
And now Trapsaw is travelling just like that.
You see the point?
Yeah.
Nice.
If you decide to delete some.
I'd say delete some.
Now you have less.
You don't have to adjust array again because you can just go to play mode.
And.
It will take all of the elements you have.
I'm still going to keep this variable open and visible so we can see how it's working.
But other than that, we're good.
This is just brilliant, I think.
All right.
This is good.
Now let me apply override.
And.
Regarding other scripts, I was pretty careful, so I think it's fine.
I'm just going to quickly check everything and then we're going to wrap this up and that's going to
be good for this section.
Yeah I think it's all super good.
Thank you so much for paying attention guys.
Let's go to the next section.
We're going to work with enemies.