WEBVTT

00:04.040 --> 00:10.400
So far, we've created a waypoint system around these palm trees for the tanks, but when we press play,

00:10.400 --> 00:14.300
it's pretty lackluster the way that they move around because there's no physics on them.

00:14.300 --> 00:16.970
So they're just going to clump together and go around the track.

00:16.970 --> 00:20.690
They're not going to hit each other or get each other off course, and they're all going at the same

00:20.690 --> 00:21.080
speed.

00:21.080 --> 00:22.760
So, you know, that's pretty boring.

00:22.760 --> 00:29.420
Once you start adding physics into a system, you basically kind of lose a little bit of control of

00:29.420 --> 00:30.980
what's going on.

00:31.070 --> 00:37.520
And therefore, you need to kind of consider all the things that could go wrong when the physics happens

00:37.520 --> 00:39.290
and be able to correct them.

00:39.290 --> 00:46.370
So let's have a look at one technique that we can use when the physics added to this kind of waypoint

00:46.370 --> 00:48.710
system causes a little bit of havoc.

00:48.740 --> 00:51.710
First of all, let's select all of our tanks.

00:51.710 --> 00:57.710
So if you just shift, select all of the tanks, we're going to add a box collider to them.

00:59.910 --> 01:03.120
And you can see the box collider sitting on those.

01:03.120 --> 01:05.700
And if I just get in a little closer here.

01:08.110 --> 01:12.550
Can't quite see it in this view yet, but there is a box collider inside and when they get a little

01:12.550 --> 01:14.290
bit bigger you'll be able to see it.

01:14.290 --> 01:20.500
And also at the same time, let's just add a rigid body because we need that for the physics system

01:20.500 --> 01:24.590
to consider these tanks as solid objects.

01:24.610 --> 01:28.000
Now with your Box Collider, you can modify it.

01:28.000 --> 01:35.620
And because you've got exactly the same model, which is the tank and you can see each of the colliders

01:35.620 --> 01:39.070
on, they can actually just resize them all at the same time.

01:39.070 --> 01:41.770
So we need to make it a bit taller.

01:41.800 --> 01:44.890
So let's just increase the height of them.

01:46.010 --> 01:53.270
We also need to make them a bit longer in the Z direction and then we also need to move it forward a

01:53.270 --> 01:56.690
little bit in the Z direction as well, and also move it up.

01:56.900 --> 02:03.490
Make sure that you move it up to a point that you can see it above the ground here.

02:03.500 --> 02:06.200
Otherwise your tank is going to fall through the ground.

02:06.200 --> 02:09.230
When you press play, let's just move it around.

02:09.230 --> 02:10.250
So there's a line here.

02:10.250 --> 02:15.950
I've just brought that up above there and now that's a better view there.

02:16.130 --> 02:22.490
You need to make it a bit wider in the X, so let's change the x size to make the tank a little bit

02:22.490 --> 02:23.480
wider.

02:26.420 --> 02:29.120
And then just have a look at what we've ended up with.

02:29.120 --> 02:34.130
Not too bad there's a bit of room in front, but that's okay now for our purposes.

02:35.000 --> 02:35.270
Right.

02:35.270 --> 02:38.830
So they've all got a collider on them, the rigid body.

02:38.840 --> 02:45.200
We're going to freeze the rotation, so go down to constraints and in the freeze rotation, freeze the

02:45.200 --> 02:46.760
X and the Z.

02:46.760 --> 02:48.620
So the tank doesn't actually flip over.

02:48.620 --> 02:52.520
It's only going to go around its Y axis, which is the up axis.

02:52.970 --> 02:53.420
Okay.

02:53.420 --> 02:56.570
We're ready to now play and have a look what happens.

02:56.570 --> 03:02.750
So press play and initially some tanks are thrown off course, but then they come back.

03:02.780 --> 03:03.980
You would have seen those two.

03:03.980 --> 03:05.800
They're the green and the yellow.

03:05.810 --> 03:06.890
Let's have another look.

03:08.740 --> 03:17.020
They have to hit that waypoint in order to come back because they have to go to each waypoint in succession.

03:17.790 --> 03:23.190
Let's make this a little bit more interesting by changing the values on each tank for the speed and

03:23.190 --> 03:23.880
the rotation.

03:23.880 --> 03:30.570
So let's make the yellow tanks rotation 15 and it speed five.

03:30.570 --> 03:32.100
So we'll actually slow it down.

03:32.100 --> 03:34.410
Let's make the blue tank go really fast.

03:34.410 --> 03:38.520
So 50 and we'll give it a rotation of eight.

03:38.670 --> 03:43.500
The red tank can go at 15, we'll leave that at ten.

03:43.500 --> 03:49.980
And the green tank, let's make that go at 40 with a rotation of three.

03:50.420 --> 03:50.880
All right.

03:50.880 --> 03:58.560
So let's now just to make it really interesting, select you select all of your tanks and control D

03:58.560 --> 03:59.850
to make a duplicate.

03:59.850 --> 04:07.770
A lot of them then hit the W key and go over in the scene and just move those tanks out and do it again.

04:11.010 --> 04:14.790
Like that and oh, let's do it again.

04:14.790 --> 04:15.450
So we got some more.

04:15.480 --> 04:16.710
Lots of tanks.

04:16.830 --> 04:22.500
All right, so now let's have a go and see what it does to our situation.

04:22.800 --> 04:23.220
Okay.

04:23.220 --> 04:29.460
So because of the initial physics and because of the settings on the car, the different settings,

04:29.460 --> 04:37.680
some of them are okay, the green cars, well, they've got a really bad turning circle, so they're

04:37.680 --> 04:39.420
getting stuck a fair bit.

04:39.420 --> 04:47.790
Now, this green car over here we have a look, has obviously made it all the way around the track until

04:47.790 --> 04:54.990
it got to this tree here and then it got knocked off of its course and has now gone around the tree.

04:54.990 --> 04:59.430
And you might have seen just then there was another green car that must have got knocked back onto course

04:59.430 --> 05:05.520
by another car and ended up coming around because now it is at this tree here because they have to go

05:05.520 --> 05:10.890
round in succession in order for them to actually progress.

05:11.310 --> 05:18.750
So this is a bit of an issue if cars can get stuck at a waypoint, especially in a race.

05:18.750 --> 05:26.160
So if you miss a waypoint and I said this previously, then you want to sort of get back on the track

05:26.160 --> 05:31.380
without trying to hit an actual single location, right?

05:31.380 --> 05:40.620
So in order to do that, you need to create an object that's going to follow the track around and then

05:40.620 --> 05:42.990
have your tank follow that object.

05:42.990 --> 05:51.240
So you want it like a super accurate progress tracker is what we're going to call it that stays on the

05:51.240 --> 05:59.370
track and then the tanks actually follow it instead, and we'll come back and implement that in the

05:59.370 --> 06:00.840
next video.
