This is a script which can be used to switch camera views based on the settings you set up in the camera views array list in the Inspector. You can adjust the position and rotation for as many different views as you like, so long as you have the keys for it.
I have initialy set it up to use keys F1 - F4 to switch between views, should you wish to add other views you will need to just copy and paste the small section of code relating to the key input statement.. which looks like this..
if (Input.GetKeyUp(KeyCode.F4))
{
_vectIndex = 3;
_cameraPosition = _viewPosition[_vectIndex];
_cameraRotation = _viewRotation[_vectIndex];
}
and change the key it is refering to and increase the _vectIndex by 1.
Pressing the TAB key will cycle through the targets that you have put into the View Target array list in the Inspector. Pressing the F5 key will lock you to that target or unlock your view from the target. (it does both).
I have fully commented the code and also explained what each part is doing in plain English so it will be even easier to understand what is doing what.
There is a little bit of homework at the end about introducing Rotation to make the camera rotate around your target when it rotates should you wish to try it for yourself.







