Andy73

CameraSwitch

Aug 7th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Script for switching between cameras within your scene.
  2.  
  3. //You can place this script on an empty gameobject in your scene,
  4. //just make sure to drag the appropriate camera into it's appropriate
  5. //slot in the inspector.
  6. // You can add more cameras if you like, make sure to add them down below into the "if" conditions
  7. //and add them up top as a public variable.
  8.  
  9. public var rearCamera : Camera ;
  10. public var driverCamera : Camera ;
  11.  
  12. function Update() {
  13.     //this is a hard wired connection to the "F1" Key on the keyboard, switch it any keyboard key if you like
  14.     //this will disable the camera inside of the car, and enable the camera outside of the vehicle
  15. if (Input.GetKey(KeyCode.F1))
  16.     {
  17.         rearCamera.camera.enabled = false;
  18.         driverCamera.camera.enabled = true;
  19.     }
  20.     //this is a hard wired connection to the "F2" Key on the keyboard, switch it any keyboard key if you like
  21.     //this will disable the camera behind the car, and enable the camera inside of the vehicle
  22. if (Input.GetKey(KeyCode.F2))
  23.     {
  24.         driverCamera.camera.enabled = false;
  25.         rearCamera.camera.enabled = true;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment