Hi Everyone, I've lately Been making an FPS Game, and There are two Cameras, One Camera is FPS and one is Third Person, I've seen Collider changes on other questions and I'm like What? So Is there a Way I Can Trigger a Camera Switch through a Binded Key?
You can activate and deactivate cameras if you can get a hold of the object that holds them.
//cameraObject is the gameObject which holds the camera
cameraObject.camera.active = false;
So If you had a script which kept track of all the cameras in your scene then you could switch cameras easily. For example here is a function which would go through an array of camera objects and turn a certain one on (based on the index sent to it).
var cameras : GameObject[];
function SelectCamera (index : int) {
for (var i : int=0 ;i<wcameras.length; i++) {
// Activate the selected camera
if (i == index){
cameras*.camera.active = true;*
*// Deactivate all other cameras*
*}else{*
_cameras*.camera.active = false;*_
_*}*_
_*}*_
_*```*_
_*<p>You could use this function by calling it with a message</p>*_
_*```*_
_*BroadcastMessage ("SelectCamera", 1);*_
_*```*_
_*<p>or by outright calling it</p>*_
_*```*_
_*SelectCamera(1);*_
_*```*_
_*<p>You just need to get hold of the instance of the script it's in</p>*_
Sure you can. The search function is your friend.
See this Answer
If you combine this with pressing a key, you should be all set.
If you want it to be more fancy and smoothly transition between both cameras, see this forum thread.