All right, so we have our actual, I guess we have a really crude first -person camera.
You can notice we have this X on our actual screen.
And the reason for that is because we're actually inside in the center of this
actual rigid body.
So we're actually looking out from it.
We're basically at the heart of this actual rigid body.
And that's why you're seeing this actual wireframe material.
What we're going to do is I'm going to go ahead and copy this out.
So I'm going to take this out, this actual character translation.
And I'm going to go ahead and assign this to our camera position.
Assign this to our camera position.
So right now, our camera position stores
our rigid body position.
If I copy this back in, we'll get the
same result.
But if I wanted to now, I can go ahead
and add or not even add.
I can just go ahead and say the camera
position .y equals 20.
Oh, maybe we'll do something like 10.
And so now we're 10 meters above our actual camera.
What I'm going to want to do is I'm going to keep the add because what we're doing
is we're basically taking the existing.
So instead of always maintaining it at
10, we're going to take the existing position.
And I'm going to add 10 to it.
So you can see now our actual camera as it's going up the stairs, our camera is
kind of going up as well as opposed to when it was actually just equal.
I was just kind of like setting it at one height, and it didn't matter whether or
not it was going upstairs.
And then what I also want to do is maybe
I'll go ahead and want to move it back.
So maybe I'd move it back to something
like 60.
And now you can see we actually have our
rudimentary third -person camera working.
What I want to do though is I actually
want to be able to target what I look at.
So in some third -person games, you have
something where the camera is actually looking over its shoulder.
And right now, our camera is essentially looking straight.
But if I wanted to directly impact where I want to look, I want to make it so that
our camera is actually facing towards our actual mesh.
I can actually go ahead and call a lookat property on our actual instance to
actually specify specifically what I want our actual camera to be looking at.
And so I'm going to do a similar thing like we did our actual camera position,
but instead I'm going to call it the camera lookat.
So now if I actually define our camera lookat at the rigid body, we can set this
offset to whatever we want, but it will ultimately still look down our actual character.
And so the way that we can actually use this actual camera lookat is we can go
ahead and call this .instance .lookat and then our camera lookat.
If I say we will get an issue, and this is similar to some of the issues we
actually ran into before.
This is actually a rapier object even
though it's a Vector3.
We have to make sure that we are creating
a new 3 .Vector3 which will actually just copy the same values as this translation.
And then because it is a 3GS Vector3, we can pass it into our actual camera lookat.
And now if I save, you can see I'm actually looking down.
I think this will be a little bit more apparent.
So for example, if I had something like
this where my Y is at like 100, you can see I'm looking straight, right?
And as expected, if I'm looking straight, the actual entire experience is
underneath me.
But if I now update our lookat position,
now you can see regardless of where I actually position my camera, you can see
that I still end up looking down at our actual character.
Now in this next part, I'm going to go ahead and show you how to implement this
with our orbit controls because there may be instances where you kind of want this
third -person controller but still have your orbit controls kind of working in
the background.
And for us, what it's going to do for us
is going to kind of give this like bouncy effect when someone tries to actually
move the camera.
It won't be immediately apparent now.
I mean, I prefer it.
If you don't, you can take it out.
But I think it's cool to show you how to actually implement this in another way.
So if we wanted to, we can re -enable our actual set controls and then
we can bring back our this controls .update.
So I can go ahead and bring back this
controls .update.
And then instead of actually targeting
our lookat, what we can do is we actually have a this .controls .target property of
our actual orbit controls.
Now if I copy the actual camera lookat
and I save, now you can see that we have it back.
And it's going to be a bit wonky because our camera controller, if I try to like
kind of pull this, it's going to try to take over.
But I'm going to actually update the way that we're setting our actual camera
position and camera lookat in the next lesson and then you can see how the
actual orbit controls can actually fit in.