1
00:00:03,030 --> 00:00:04,770
In this lecture, we're adding another method.

2
00:00:04,770 --> 00:00:08,370
We're adding a transformed translate so we can move our car forward.

3
00:00:08,370 --> 00:00:13,620
And by the end of this video, we'll have our car rotating around and moving forward at the same time.

4
00:00:13,620 --> 00:00:14,580
Let's get started.

5
00:00:14,580 --> 00:00:18,810
We use Transformed Rotate in the previous lecture to rotate our car.

6
00:00:18,810 --> 00:00:23,220
Now we're going to use transform, translate to move the car forward.

7
00:00:23,220 --> 00:00:27,360
We also need to provide the X, Y and z amounts.

8
00:00:27,360 --> 00:00:29,760
We want to move just like we did in rotate.

9
00:00:29,760 --> 00:00:36,780
Let we jump back to rotate over here by opening up my driver script in rotate, we needed an x, y and

10
00:00:36,990 --> 00:00:38,460
z value in there.

11
00:00:38,460 --> 00:00:42,750
In terms of how much rotate, we need to do the same for translate and I'm going to give you these to

12
00:00:42,750 --> 00:00:43,440
you as a challenge.

13
00:00:43,440 --> 00:00:49,740
But first I'm going to comment out our rotation so that we only focusing on the translate for the moment.

14
00:00:49,740 --> 00:00:54,540
We'll uncomment this after we've done translate, but we're going to comment this out for the moment

15
00:00:54,540 --> 00:00:58,020
and I want you as a challenge to make our car move forward.

16
00:00:58,020 --> 00:01:04,890
So in upstate coal transform, translate just as we did with the rotate, we're going to do this with

17
00:01:04,890 --> 00:01:11,790
translate and add the X, Y and Z values you think we need to add in there so that our car slowly moves

18
00:01:11,790 --> 00:01:12,720
forward.

19
00:01:12,720 --> 00:01:18,000
There's a little bit of figuring out going on to do that, but pause the video, take on this challenge.

20
00:01:18,000 --> 00:01:19,950
I'll see you back here when you've given it your best shot.

21
00:01:21,800 --> 00:01:22,400
Okay.

22
00:01:22,400 --> 00:01:28,490
So let us add our new line transform, dot translate.

23
00:01:28,490 --> 00:01:32,960
And you can see I get a couple of letters into it and Visual Studio code saying I think you might want

24
00:01:32,990 --> 00:01:35,330
translate, you can hit space or tab.

25
00:01:35,330 --> 00:01:37,670
I usually use Tab to complete that word.

26
00:01:37,670 --> 00:01:39,290
It's a little bit handy to autocomplete.

27
00:01:39,290 --> 00:01:41,030
We need our parentheses.

28
00:01:41,060 --> 00:01:41,450
Okay.

29
00:01:41,450 --> 00:01:45,890
Now we need to be adding in here the X, Y and Z as we did with our rotate.

30
00:01:45,890 --> 00:01:50,030
I'm not exactly sure what we need, so let's jump back over into unity and have a look.

31
00:01:50,030 --> 00:01:57,050
If I scroll in, click on Cruisy Mic Drive and you can see I want him to go forwards to drive up in

32
00:01:57,050 --> 00:01:58,100
the car direction.

33
00:01:58,100 --> 00:02:05,030
So if I move upwards, what's happening over here in our transform, you can see I'm translating on

34
00:02:05,030 --> 00:02:10,880
the y axis, so I want the Y to be changing and moving in a positive direction.

35
00:02:10,880 --> 00:02:15,560
And that means that when I pop in here, the first one is X, the second one is Y, and the third one

36
00:02:15,560 --> 00:02:15,890
is Z.

37
00:02:15,890 --> 00:02:16,880
So I need zero.

38
00:02:16,880 --> 00:02:21,890
Don't want to move any on the X and then I'm going to put in here one and I think they might be a bit

39
00:02:21,890 --> 00:02:25,580
too big, but I'll put it in any way and then zero because I don't want to move any on the Z and then

40
00:02:25,580 --> 00:02:26,930
the semicolon at the end.

41
00:02:26,930 --> 00:02:28,190
Let's save that.

42
00:02:28,340 --> 00:02:30,320
Let's look to see what happens here.

43
00:02:30,320 --> 00:02:32,270
And I kind of know a little bit what's going to happen.

44
00:02:32,270 --> 00:02:36,740
So I'm going to zoom my camera out a little bit and then click on play.

45
00:02:36,740 --> 00:02:41,810
So every frame we are going to move from way off the screen, we're going to move one on the Y axis.

46
00:02:41,810 --> 00:02:44,210
So we'll jump back into here as we do with rotate.

47
00:02:44,210 --> 00:02:50,270
We'll make this I'm going to make it 0.01 f remember if you're using decimal places, we want to pop

48
00:02:50,270 --> 00:02:51,440
an F down the end.

49
00:02:51,440 --> 00:02:52,400
Save that.

50
00:02:52,400 --> 00:02:55,010
We'll see if this is a little bit more of sensible movement.

51
00:02:55,100 --> 00:03:02,180
I'm going to click on play once we're finished doing all this compiling and we should see slowly heading

52
00:03:02,180 --> 00:03:03,320
in a forward direction.

53
00:03:03,320 --> 00:03:03,620
Excellent.

54
00:03:03,620 --> 00:03:04,610
That's what we wanted to do.

55
00:03:04,610 --> 00:03:05,900
Now I can do something a little bit tricky.

56
00:03:05,900 --> 00:03:09,650
I'll uncomment our rotate and save.

57
00:03:09,650 --> 00:03:14,930
Make sure you always save, jump back over into unity and I'm going to move my car over to the right

58
00:03:14,930 --> 00:03:19,100
because I know already that when we rotate, we're going to be heading rotating in a left.

59
00:03:19,100 --> 00:03:19,550
What's that?

60
00:03:19,550 --> 00:03:23,150
Left is anti clockwise or counterclockwise direction.

61
00:03:23,150 --> 00:03:27,110
So when I click on play now we're going to move forward a bit, rotate a bit, forward a bit, rotate

62
00:03:27,110 --> 00:03:28,370
a bit forward a bit, rotate a bit.

63
00:03:28,370 --> 00:03:31,250
That's how we're going to drive around in this nifty kind of circle.

64
00:03:31,250 --> 00:03:36,320
So we've now added translate to move our vehicle forward on the Y axis.

65
00:03:36,320 --> 00:03:41,060
And we still have in our rotate there and we're rotating around the Z axis to have our vehicle just

66
00:03:41,060 --> 00:03:42,410
going around and around in circles.

67
00:03:42,410 --> 00:03:47,840
Not much of a game just yet, but we're well on our way to adding player control so we can make a game.

68
00:03:47,870 --> 00:03:48,320
Good work.

69
00:03:48,320 --> 00:03:49,460
I'll see you in the next lecture.

