Camera System

Table of Contents

RCCP uses a single camera that switches between modes rather than placing multiple camera GameObjects in your scene. The main RCCP_Camera component parents itself to different positions depending on the active mode. This keeps your hierarchy clean and avoids the overhead of maintaining multiple cameras.

For general project setup, see Installation. For vehicle configuration, see Vehicle Setup.


Camera Setup

Adding the Camera to Your Scene

Use the Unity menu:

Tools > BoneCracker Games > Realistic Car Controller Pro > Create > Scene > Add RCCP Camera

This instantiates the RCCP Camera prefab referenced in RCCP_Settings. The prefab contains:

How Targeting Works

RCCP_Camera uses a CameraTarget class that holds:

FieldTypeDescription
playerVehicleRCCP_CarControllerThe vehicle the camera follows
HoodCameraRCCP_HoodCameraAuto-found on the vehicle via GetComponentInChildren
WheelCameraRCCP_WheelCameraAuto-found on the vehicle via GetComponentInChildren

When a vehicle is registered as the player vehicle through RCCP_SceneManager, the camera's SetTarget() method is called automatically. If TPSAutoFocus is enabled (the default), the camera smoothly adjusts its distance and height to fit the vehicle's bounds.


Camera Modes

The CameraMode enum defines all available modes:

ModeEnum ValueDescription
Third-PersonTPSDefault follow camera behind the vehicle
First-Person / HoodFPSView from inside the vehicle (dashboard area)
WheelWHEELClose-up view near a wheel
FixedFIXEDScene-placed camera that watches the vehicle pass by
CinematicCINEMATICAuto-tracking camera with animation support
Top-DownTOPOverhead view, optionally orthographic
Truck-TrailerTRUCKTRAILERSpecialized TPS mode for vehicles towing trailers

Enabling and Disabling Modes

Each mode (except TPS and TRUCKTRAILER) can be toggled on or off. When a mode is disabled, the camera skips it when cycling:

PropertyDefaultControls
useHoodCameraModetrueFPS mode availability
useWheelCameraModetrueWHEEL mode availability
useFixedCameraModetrueFIXED mode availability
useCinematicCameraModetrueCINEMATIC mode availability
useTopCameraModefalseTOP mode availability

TPS mode is always available and is the fallback when other modes encounter issues (such as occlusion in Wheel mode).


Third-Person Mode (TPS)

The TPS camera follows behind the vehicle at a configurable distance and height. RCCP provides two TPS sub-modes:

Sub-ModeEnumCharacteristics
TPS1TPSMode.TPS1Original implementation using SmoothDampAngle per axis
TPS2TPSMode.TPS2More stable approach using Quaternion.Slerp, includes drift support

Select the sub-mode via the tPSMode property. TPS2 is the default and recommended choice.

Transform Settings

PropertyRangeDefaultDescription
TPSDistance0 - 206.5Distance behind the vehicle
TPSHeight0 - 101.5Height above the vehicle
TPSOffsetVector3(0, 0, 0.2)Local offset relative to the vehicle
TPSRotationDamping0 - 10.5Smoothing factor for rotation tracking
TPSPitch-45 to 457.5Downward pitch angle
TPSYaw-45 to 450Lateral yaw offset

Rotation Locking

These control which vehicle rotation axes the camera follows:

PropertyDefaultEffect
TPSLockXtrueCamera tracks vehicle pitch
TPSLockYtrueCamera tracks vehicle yaw
TPSLockZfalseCamera tracks vehicle roll

Dynamic Camera

When TPSDynamic is enabled, the camera distance, height, and pitch angle shift based on the vehicle's acceleration. This creates a more cinematic feel during rapid speed changes. The system uses a hidden TPSAccelerationPoint transform to smooth the acceleration offset.

Speed-Based FOV

The field of view interpolates between TPSMinimumFOV and TPSMaximumFOV based on vehicle speed, creating a sense of velocity.

PropertyRangeDefaultDescription
TPSMinimumFOV10 - 9040FOV when stationary
TPSMaximumFOV10 - 16060FOV at high speed

Auto Focus

When TPSAutoFocus is true (the default), SetTarget() triggers a coroutine that calculates the vehicle's bounding-box extent and smoothly adjusts TPSDistance and TPSHeight over 2 seconds. This ensures each vehicle is framed correctly regardless of its size.

Auto Reverse

When TPSAutoReverse is true (the default), the camera automatically rotates 180 degrees to look forward when the vehicle reverses.

Camera Tilt

The camera tilts along the Z axis based on lateral velocity, creating a leaning effect during turns:

PropertyRangeDefaultDescription
TPSTiltMaximum0 - 2515Maximum tilt angle in degrees
TPSTiltMultiplier0 - 1.51Multiplier to fine-tune tilt intensity

Camera Shake

When TPSShake is true (the default), the camera applies subtle Perlin noise-based positional and rotational shake that increases with vehicle speed. Maximum shake occurs around 260 km/h.

Free Fall Behavior

When TPSFreeFall is true (the default), the camera rotation damping drops to near zero while the vehicle is airborne. This means the camera holds its orientation in the air rather than tracking the vehicle's tumbling.


Hood Camera (FPS Mode)

The hood camera provides a first-person view from inside the vehicle, typically at dashboard level.

Setup

  1. Create an empty GameObject as a child of your vehicle.
  2. Position it where the driver's eyes would be (on or near the dashboard).
  3. Add the RCCP_HoodCamera component to it.
  4. (Optional) Add a ConfigurableJoint and Rigidbody to reduce camera shake. The component auto-connects the joint to the vehicle's Rigidbody on start.

The RCCP_Camera finds the RCCP_HoodCamera on the target vehicle automatically via GetComponentInChildren.

FOV

The hood camera uses hoodCameraFOV on the RCCP_Camera component (default 60, range 10-160 degrees).

Orbit in Hood Mode

When useOrbitInHoodCameraMode is true (the default), the player can look around using mouse or touch input while in FPS mode.


Wheel Camera

The wheel camera provides a low-angle close-up of a vehicle wheel.

Setup

  1. Create an empty GameObject as a child of your vehicle, near one of the wheels.
  2. Orient it to point at the wheel.
  3. Add the RCCP_WheelCamera component.

The RCCP_Camera finds it automatically. If occlusion is detected (an obstacle between the camera and the vehicle), the camera automatically reverts to TPS mode.

FOV

The wheel camera uses wheelCameraFOV on the RCCP_Camera component (default 60, range 10-160 degrees).


Fixed Camera

The RCCP_FixedCamera is a singleton placed in the scene. When active, the RCCP Camera parents itself to the fixed camera's position. The fixed camera:

Setup

  1. Add an RCCP_FixedCamera component to a GameObject in your scene.
  2. Set maxDistance to control how far the vehicle can travel before the camera relocates.
  3. Configure minimumFOV (default 20) and maximumFOV (default 60) for zoom behavior.

Only one RCCP_FixedCamera should exist in a scene (it is a singleton).


Cinematic Camera

The RCCP_CinematicCamera is a singleton that smoothly tracks the vehicle from a trailing position. It includes a Pivot child GameObject that can hold Unity animations for camera movement.

Setup

  1. Add an RCCP_CinematicCamera component to a GameObject in your scene.
  2. Optionally, add animations to its Pivot child for sweeping camera motions.
  3. Use RCCP_FOVForCinematicCamera on the Pivot to feed animated FOV values back to the cinematic camera.

The cinematic camera rotates smoothly toward the vehicle's heading and maintains a following distance of about 10 meters.


Top-Down Camera

The top-down camera provides an overhead view, useful for racing games with a top-down perspective.

PropertyDefaultDescription
topCameraAngle(45, 45, 0)Euler angle of the overhead view
topCameraDistance100Distance from the vehicle
maximumZDistanceOffset10Forward offset based on speed
useOrthoForTopCamerafalseIf true, switches to orthographic projection
minimumOrtSize10Orthographic size when stationary
maximumOrtSize20Orthographic size at speed

The camera position lerps smoothly toward the vehicle and adjusts the forward offset based on vehicle speed.


Truck-Trailer Camera

When a vehicle has a connected trailer (RCCP_TrailerController), the TPS mode automatically switches to TRUCKTRAILER. This mode:

When the trailer is disconnected, the camera automatically reverts to standard TPS mode.


Orbit Controls

Orbit allows the player to rotate the camera around the vehicle using mouse or touch input in TPS and Hood modes.

Settings

PropertyDefaultDescription
useOrbitInTPSCameraModetrueEnable orbit in TPS
useOrbitInHoodCameraModetrueEnable orbit in Hood/FPS
useOrbitOnlyHoldingtrueOrbit only while mouse button is held
orbitXSpeed100Horizontal orbit speed
orbitYSpeed100Vertical orbit speed
orbitSmooth25Smoothing factor
minOrbitY-15Minimum vertical angle
maxOrbitY70Maximum vertical angle
orbitResettrueAuto-reset orbit when vehicle is moving

Mobile Orbit

For mobile touch input, call RCCP_Camera.OnDrag(PointerEventData) from a UI drag panel. This feeds touch delta into the orbit system.

Look-Back

The lookBackNow property rotates the camera 180 degrees to face behind the vehicle. This is triggered by the look-back input binding (see Inputs).


Zoom

In TPS mode, mouse scroll input adjusts the camera distance:

PropertyRangeDefaultDescription
zoomScrollMultiplier0.5 - 105Sensitivity of scroll zoom
minimumScroll0+0Minimum zoom offset
maximumScroll0+5Maximum zoom offset

Occlusion / Collision Detection

When useOcclusion is true (the default), the camera performs a SphereCast from the vehicle toward the desired camera position. If the ray hits a collider (excluding vehicle layers and triggers), the camera repositions to the hit point plus a small normal offset. This prevents the camera from clipping through walls and terrain.

The occlusionLayerMask controls which layers are checked. By default, it includes all layers except RCCP vehicle layers.


Auto-Change Camera

When useAutoChangeCamera is enabled, the camera automatically cycles to the next available mode every 10 seconds. The autoChangeCameraTimer property tracks the current countdown. This is useful for demo scenes and attract modes.


Switching Camera at Runtime

Cycle to Next Mode


// Using the static API
RCCP.ChangeCamera();

// Or directly on the camera component
RCCP_SceneManager.Instance.activePlayerCamera.ChangeCamera();

Switch to a Specific Mode


RCCP_Camera cam = RCCP_SceneManager.Instance.activePlayerCamera;
cam.ChangeCamera(RCCP_Camera.CameraMode.TOP);

Toggle Camera On/Off


RCCP_Camera cam = RCCP_SceneManager.Instance.activePlayerCamera;
cam.ToggleCamera(false); // Disables rendering
cam.ToggleCamera(true);  // Re-enables rendering

Showroom Cameras

RCCP includes two additional camera components for menus and vehicle selection screens.

RCCP_ShowroomCamera

An orbiting camera for main menus and vehicle showcases.

PropertyDefaultDescription
target(none)Transform to orbit around
distance8Distance from target
orbitingNowtrueEnable auto-rotation
orbitSpeed5Auto-rotation speed
smoothtrueSmooth position/rotation interpolation
smoothingFactor5Interpolation speed
minY / maxY5 / 35Vertical angle limits
dragSpeed10Manual drag rotation speed

Call OnDrag(PointerEventData) from a UI element to enable player-controlled rotation. Use ToggleAutoRotation(bool) to start or stop automatic orbiting.

RCCP_CameraCarSelection

A simpler orbiting camera specifically for vehicle selection UIs. It automatically rotates around the target at a fixed angle and distance. No manual drag input by default.

PropertyDefaultDescription
target(none)Transform to orbit around
distance5Distance from target
speed25Rotation speed
angle10Vertical viewing angle

Common Issues

Camera Does Not Follow the Vehicle

Camera Clips Through Walls

Hood or Wheel Camera Is Skipped

Camera Shakes Excessively in Hood Mode

Truck-Trailer Mode Activates Unexpectedly


Related Topics


Support: bonecrackergames@gmail.com | www.bonecrackergames.com

Need help? See Troubleshooting