So, let's
get to fixing the 3rd person camera rotation! What we're
going to do in this video is organize our blueprint a little bit differently in the tank
with an Azimuth Gimbal, as we call it, and some slight changes in rotations
in the SpringArm, so that firstly the tank
camera works properly, and secondly, the horizon always stays
horizontal, or at least optionally always stays horizontal, even if the tank is tilted like this, because of say a hill.
So, let's take a closer look at what's going on with this rotation. We want to use
something called Gimbals. You probably want to search for that with text, not with
voice, just in case it goes wrong. But Gimbals will be somewhere on
trusty Wikipedia. Here you go! The features of a Gimbal is, it's a support that
"allows the rotation of an object about a single axis." So, we're going to be using a
couple of Gimbals. So, let's take a look at the
tank blueprint and see what we need to do to make the camera rotation
behave itself. Well, we have this SpringArm and we can visualize that
here in the viewport as basically an arm that sits
here, and it's actually got a red length to it and we've actually
currently got our camera in the wrong place. It's not at the
end of the SpringArm. So, let's fix that, choose your camera, and reset the location,
pushing it onto the end of the SpringArm. So, now you may say, well how do we
position our camera? Well, what you need to do is change the length of the Spring
Arm, so the SpringArm has a Target Arm Length here.
And we set that to say, I don't know, 1,000, you know 10 meters, something like
that and then we're in better shape. So, now the camera will stay on
the end of the SpringArm. I'm going to remove the camera's
Rotation for now, and of course, if we were to play now the camera would just be on the floor
behind the tank but we still have this strange rotational issue.
So, what we want to do is, we want a couple of Gimbals, one
which allows rotation of the camera in this
plane. Probably use this to just show you. Get the rotation tool up this way
in Azimuth. OK, so let's do that first! How do we do that? Well,
we can't do it all in one object without twisting the camera. Imagine
this was plugged into a ball joint. If it's plugged into a ball joint, we can end up with the
wrong type of rotation. You see how as I rotate the camera both in Azimuth and Elevation,
you see how it's ending up on the tilt like that? We don't want
it on the tile right? So, what we want to do is put yourself
a Scene root component, it's basically a simple
transform, into the scene. Put
that on the Tank. If you accidentally put it at the root like I did, then just
put the Tank back at the root, but the Scene root wants to be on the Tank.
Then, put the SpringArm into the Scene root. Now, I'm going to rename these things, because it's not
very helpful just calling it Scene. What this thing is, is it's an Azimuth
Gimbal
OK. So, this thing will allow this rotation Aximuth
Gimbal. Great! Then, the SpringArm itself
is a SpringArm and it also provides for elevation.
So, I think I'm going to just leave it called a SpringArm, but we are only going to
control it in Elevation, so I'm going to move it up a little bit. The Azimuth
Gimbal position, I'm going to actually put that, rather than at the middle of the tank, this is
where the camera's pointing at. We want it pointing about 1 1/2 meters off the ground.
So in summary, we have a Scene root component that says, this is
where the camera's pointing at, if it points straight down the SpringArm, which it currently is,
and the location of that is 1.5 meters
off the ground in the middle of the tank. You then have a SpringArm about 10 meters
long, rotated up like this, and on the end of that you have a camera, probably with no
rotation. OK, let's take a look at how it works! It's pretty good! We've still got the
weirdness. So, what do we do about the weirdness? The weirdness is because
I said that the Azimuth Gimbal is only driving the Azimuth, and the SpringArm
is going to be doing the Elevation only, like this. So, Elevation
happens here like that. Azimuth happens here
in the Azimuth Gimbal. OK, so what do we do? We go
over to the Input Setup. We already have a reference to the SpringArm
and let's have a look! Azimuth we said is being done by the
Azimuth Gimbal. So, what we need to do is get rid of the SpringArm there, pop in a reference to the
Azimuth Gimbal, by dragging from the components, and it's that
that becomes the target of an Azimuth rotation. So, the Azimuth Gimbal
handles the Azimuth rotation, and the AimElevation is
handled by the SpringArm itself. Let's try this! This is about 90
percent of the solution we're looking for! Left and right and up and down and it
works exactly as we want, but let's see what happens if we put the
camera or the tank on a piece of sloping ground. So I think, at this stage,
I'm going to sculpt the terrain a little, so we need some test grounds here. So, I'm just going to
pop into the Landscape, Molding Tool, and the Sculpt Tool.
I'm just going to bring up some landscape here, that we can start
to use. Remember that fragmentation of the components of the landscape is expected, before it rebuilds
the lighting. And I've got a little bit of land here, so let's
just try going to the tank, the Player Start rather.
Then, you need to come out of Landscape Sculpting Mode, at which point
you'll be able to move the Player Start, and I'm just going to move this Player Start above the hill
and let the tank fall onto the slope. Let's try it!
You see, as the tank rotated on the slope,
you see that our whole camera has rotated. That's OK, that's a choice as to
whether we want the horizon to rotate. If we don't want the horizon to
rotate, then the way that we deal with that is, in the Spring Arm itself,
you can say don't Inherit the Roll of the thing you're connected to.
So, in the SpringArm's Camera Settings, you can disable Inherit Roll,
and then, what'll happen when we fall and twist is that the
horizon stays horizontal and then the tank itself appears to twist in our
view. So, this is the camera being like gyro stabilized in roll.
I hope that all makes sense to you. So, that's how I'm going to leave things. I may as well
spawn on this hillside. Why not for a bit of fun? I'm just going to recap
exactly what's happened here for you, so that it's clear how to do these more
complicated 3rd person cameras. So, because we need control
of the Azimuth and the Elevation, we've decided to put a object at the
target of the camera, and we're calling it an Azimuth Gimbal. So, that is like
a... It's a bit like the turret actually.
It's the same type of rotation that we get wth the turret itself. It's just a
horizontal rotation, so that would be like a kind of peg sticking up if
you like. Onto the peg is attached a SpringArm, which we can,
because of a hinge or another Gimbal, we can choose different heights, and we're only
controlling the Elevation with that. So, if you look at the Input Setup, you can
see that Azimuth, Elevation.
And then, what we're doing is, we're pointing the camera straight down the SpringArm, we don't have to but we're doing
that, and because, when the tank rotates
the whole system rotates, i.e. the tank
and the SpringArm and the camera rotate, when the tank's on the side. Of course, the view of
the horizon becomes tilted, because the camera and the tank
are tilted, relative to the horizon. So, the final thing we did is, we went to the SpringArm
and said, well don't let the camera on the end of the SpringArm Inherit the
Roll of the SpringArm, and hence the tank and hence the SpringArm.
Alright, so we finally end up in the situation where we have the camera
how we want it. Pretty cool! So, that's it
for this video! And I haven't got a challenge for you in this one, because it's really
just a question of following me through, but what I would say if you haven't been doing what I've been
doing as you go is, just get this setup to your satisfaction. You don't have us the exact
settings I'm using right? You could have the camera a little bit farther away,
you could decide that actually you want to Inherit the Roll and that you quite like
this camera going with the tank. It's up to you.
Alright, it's not going to affect the game play at all! So, just set the camera up how you want it now,
and I'll see you in the next video!