In this lecture, we're adding another method.
We're adding a transformed translate so we can move our car forward.
And by the end of this video, we'll have our car rotating around and moving forward at the same time.
Let's get started.
We use Transformed Rotate in the previous lecture to rotate our car.
Now we're going to use transform, translate to move the car forward.
We also need to provide the X, Y and z amounts.
We want to move just like we did in rotate.
Let we jump back to rotate over here by opening up my driver script in rotate, we needed an x, y and
z value in there.
In terms of how much rotate, we need to do the same for translate and I'm going to give you these to
you as a challenge.
But first I'm going to comment out our rotation so that we only focusing on the translate for the moment.
We'll uncomment this after we've done translate, but we're going to comment this out for the moment
and I want you as a challenge to make our car move forward.
So in upstate coal transform, translate just as we did with the rotate, we're going to do this with
translate and add the X, Y and Z values you think we need to add in there so that our car slowly moves
forward.
There's a little bit of figuring out going on to do that, but pause the video, take on this challenge.
I'll see you back here when you've given it your best shot.
Okay.
So let us add our new line transform, dot translate.
And you can see I get a couple of letters into it and Visual Studio code saying I think you might want
translate, you can hit space or tab.
I usually use Tab to complete that word.
It's a little bit handy to autocomplete.
We need our parentheses.
Okay.
Now we need to be adding in here the X, Y and Z as we did with our rotate.
I'm not exactly sure what we need, so let's jump back over into unity and have a look.
If I scroll in, click on Cruisy Mic Drive and you can see I want him to go forwards to drive up in
the car direction.
So if I move upwards, what's happening over here in our transform, you can see I'm translating on
the y axis, so I want the Y to be changing and moving in a positive direction.
And that means that when I pop in here, the first one is X, the second one is Y, and the third one
is Z.
So I need zero.
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
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
the semicolon at the end.
Let's save that.
Let's look to see what happens here.
And I kind of know a little bit what's going to happen.
So I'm going to zoom my camera out a little bit and then click on play.
So every frame we are going to move from way off the screen, we're going to move one on the Y axis.
So we'll jump back into here as we do with rotate.
We'll make this I'm going to make it 0.01 f remember if you're using decimal places, we want to pop
an F down the end.
Save that.
We'll see if this is a little bit more of sensible movement.
I'm going to click on play once we're finished doing all this compiling and we should see slowly heading
in a forward direction.
Excellent.
That's what we wanted to do.
Now I can do something a little bit tricky.
I'll uncomment our rotate and save.
Make sure you always save, jump back over into unity and I'm going to move my car over to the right
because I know already that when we rotate, we're going to be heading rotating in a left.
What's that?
Left is anti clockwise or counterclockwise direction.
So when I click on play now we're going to move forward a bit, rotate a bit, forward a bit, rotate
a bit forward a bit, rotate a bit.
That's how we're going to drive around in this nifty kind of circle.
So we've now added translate to move our vehicle forward on the Y axis.
And we still have in our rotate there and we're rotating around the Z axis to have our vehicle just
going around and around in circles.
Not much of a game just yet, but we're well on our way to adding player control so we can make a game.
Good work.
I'll see you in the next lecture.