Okay, let's start by creating our two cameras that are going to be essential to make this
whole thing work.
So let's start by creating our third person camera.
So go to Cinemachine, create virtual camera, and this could be called CM-CAML1, or if it
helps you, third person, just to keep it known to you.
In the body, we want to use a third person follow camera.
And let's see my main camera.
We look good here.
I need to attach this to my capsule.
So I'm going to set this to my follow.
And now, if we look, my camera is following correctly, I will adjust the offset to a more
first person or third person perspective.
I like having it a little more offset so that if you do happen to be shooting a gun, you
see down the gun perspective versus like through your player's head.
And then you can kind of swap sides from left to right depending on if you're on the
left hand or the right hand side of the gun.
And then in the composer, I'm going to do the same as follow target.
So my camera always remains up in front.
And then if I press play, if I turn left, you could see that my camera is following.
If I turn right, and if I move forward, if I move back, this camera moves exactly how
I want it to.
You can go in and start adjusting the dampening as well so that it's a little more organic
and less rigid and stringy.
Okay, so that's my first camera.
I really like that.
Now I'm going to create a second camera.
I'm going to create a second virtual camera.
And this virtual camera is going to look at the capsule and it's going to follow the capsule.
And we are going to use the orbital transposer.
And now I'm going to click the solo button.
So I'm looking through the orbital transposer.
I'm going to change to Z depth.
I'm going to bring this a little up higher.
And then I want to go ahead and press play.
And if I go to my solo mode of my V cam, and if I'm looking at it from this perspective,
you could see how if I hold the mouse button, I can rotate around.
And I really like this camera perspective of my orbital.
So this will be my orbital cam.
Now, how do we move between the two?
It's actually incredibly simple.
Let's create a script.
So right click, create, C sharp script, switch cam, bool.
And then we can just go ahead and take this and place this onto our camera or our character
controller.
So I'm going to do the switch cam, bool.
I'm going to place this under here.
And we're going to go ahead and edit this script.
And all we need to do is we just need to go ahead and grab the virtual cameras.
And we just need to enable the one we don't want to use when we hold the right click on
the mouse button.
I'm going to go ahead and grab a serialized field, private game object, VC1.
And I'll do a serialized field, private game object, VC2.
Let's go ahead and save this.
Inside our character controller, I want to drop in our camera one and our camera two.
And then when I do an input, and I want to make sure that it's the get key, which is
determining if it's held down, the key is key code.
And I believe it's the mouse.
Mouse was a key code dot mouse 01, which is our right mouse button.
And that happens.
I actually want to turn off the VC2.
So I'm going to go to VC2.setActive is false.
And that will turn off VC2.
And if I have the input dot get key up, and the key code is mouse 01.
So if the mouse button comes up, I want to set VC2 to true.
So if I hold it down, the orbital, actually I should do the VC1 is true.
And VC2, yeah, this will be work.
So if I hold this down, VC1, which is the third person camera is now false.
And that leaves the orbital camera as the only one that's true.
So let's test this out.
I'm going to hit play.
And right now, I'm in the third person camera.
If I hold the right mouse button down, you can see I go to orbital.
And if I let go, it snaps back to third person.
Orbital third person.
Really easy to do.