FollowCamera
Introduction
The FollowCamera
component is designed to track a specified target object within the scene. It is attached to the main camera and maintains a defined distance and height from the target. Additionally, it offers the flexibility of custom rotation around the target as an optional feature.
Elements configurable from the editor level
Required member
Target
- the transform component of the tracked object
Base Setttings
Distance
- base distance between the camera and the target objectOffset
- lateral offset of the camera positionHeight
- base height of the camera above the target objectHeightMultiplier
- camera height multiplier
Optional Movement Setttings
RotateAroundModeToggle
- toggle key between rotate around mode and default follow modeRotateAroundSensitivity
- mouse movement sensitivity for camera rotation around the targetHeightAdjustmentSensitivity
- mouse movement sensitivity for camera height adjustmentZoomSensitivity
- mouse scroll wheel sensitivity for camera zoomInvertHorzAxis
- invert horizontal mouse movementInvertVertAxis
- invert vertical mouse movementInvertScrollWheel
- invert mouse scroll wheelMaxHeight
- maximum value of camera heightMinDistance
- minimum value of camera distance to target objectMaxDistance
- maximum value of camera distance to target object
Rotate Around Mode
Camera rotation around the target can be activated by pressing the RotateAroundModeToggle
key (default 'C'
key). In this mode, the user can manually adjust the camera view at run-time using the mouse. To deactivate the Rotate Around mode, press the RotateAroundModeToggle
key once more.
In the Rotate Around Mode camera view can be controlled as follows:
hold left shift + mouse movement
: to adjust the camera position,hold left shift + mouse scroll wheel
: to zoom in or out of the camera view,left shift + left arrow
: to set left camera view,left shift + right arrow
: to set right camera view,left shift + up arrow
: to set front camera view,left shift + down arrow
: to set back camera view.
Optional
An optional prefab featuring a UI panel, located at Assets/Prefabs/UI/MainCameraView.prefab
, can be used to showcase a user guide. To integrate this prefab into the scene, drag and drop it beneath the Canvas object. This prefab displays instructions on how to adjust the camera view whenever the Rotate Around Mode is activated.