| 1 | {{{ #!Markdown |
| 2 | |
| 3 | # CameraControl |
| 4 | |
| 5 | Controls the main camera of the scene, providing different views and camera options. |
| 6 | |
| 7 | The main camera is a GameObject at the top level of the scene containing a Camera component. You can configure the camera's parameters as usual. The script expects the following components to be also present: |
| 8 | |
| 9 | >CamSmoothFollow |
| 10 | CamMouseOrbit |
| 11 | CamSmoothLookAt |
| 12 | CamFreeView |
| 13 | CamFixTo |
| 14 | CamSmoothLookAtPointFromPos |
| 15 | |
| 16 | These scripts provide the camera modes. They are controlled from CameraControl. Note that some of them are scripts from the Standard Assets with specific adjustments and modifications. |
| 17 | |
| 18 | #### Camera modes |
| 19 | |
| 20 | CameraControl provides six different camera modes, which are invoked from [CarInput][] through the public functions _Next_ and _SwitchTo_: |
| 21 | |
| 22 | __0 -__ Driver's View (_CamFixTo_) |
| 23 | __1 -__ Follow Vehicle (_CamSmoothFollow_) |
| 24 | __2 -__ Mouse View (_CamMouseOrbit_) |
| 25 | __3 -__ Static Position (_CamSmoothLookAt_) |
| 26 | __4 -__ Free Camera (_CamFreeView_) |
| 27 | __5 -__ Vehicle To Vehicle (_CamSmoothLookAtPointFromPos_) |
| 28 | |
| 29 | In the [live demo][] you can use the keys C or F1-F6 to select the camera mode. Press H for help on further keys that controls the camera's movement and zoom. |
| 30 | |
| 31 | ## CameraControl parameters |
| 32 | |
| 33 | The [CarInput][] script controls most of these parameters according to the user's input. |
| 34 | |
| 35 | __Target__: reference to the vehicle that is being followed. __It must contain a [CarCameras][] component.__ |
| 36 | |
| 37 | __Target2__: optional reference to a secondary vehicle to be used in the _Vehicle to vehicle_ mode. |
| 38 | |
| 39 | __MapCamera__: optional reference to a camera showing a mini map. This camera is an orthographic camera with a SmoothFollow script configured to keep the camera pointing down above the vehicle. |
| 40 | |
| 41 | __defaultCamera__: camera mode to be used at startup. |
| 42 | |
| 43 | __showMirrors__: enables the mirrors (if available) in the Driver's view. |
| 44 | |
| 45 | __MirrorLeftTex, MirrorRightTex, MirrorRearText__: optional references to the GUITexture components that show the mirror images. Their containing GameObjects must have their transform configured to locate the textures properly on the screen. |
| 46 | |
| 47 | __enableImageEffects__: determines whether the referenced in the _ImageEffects_ list (below) are enabled or not. |
| 48 | |
| 49 | #### ImageEffects |
| 50 | |
| 51 | You can include the image effects of your choice (Component > Image Effects at Unity) in the main camera's GameObject. Optionally, you can reference these image effects here. This will allow all the effects to be enabled or disabled with the _enableImageEffects_ property, providing a "low quality" mode for the camera. |
| 52 | |
| 53 | The [live demo][] uses two image effects, _ColorCorrectionCurves_ and _ContrastStretchEffect_. The "low quality mode" can be toggled with the key F12, which also disables the shadows. |
| 54 | |
| 55 | [CarInput]: wiki:CarInput |
| 56 | [CarCameras]: wiki:CarCameras |
| 57 | [live demo]: http://www.edy.es/unity/offroader.html |
| 58 | |
| 59 | }}} |