API Reference

Table of Contents

Overview

RCCP provides a static API class (RCCP) that serves as the primary entry point for all vehicle operations. Use this class to spawn vehicles, control them, switch behaviors, manage the camera, and more.

All methods are static and can be called from anywhere:


using UnityEngine;

public class MyGameManager : MonoBehaviour {
    public RCCP_CarController vehiclePrefab;

    void Start() {
        RCCP.SpawnRCC(vehiclePrefab, Vector3.zero, Quaternion.identity, true, true, true);
    }
}

Spawn and Registration

RCCP.SpawnRCC

Instantiate a vehicle from a prefab and optionally register it as the player vehicle.


RCCP_CarController RCCP.SpawnRCC(
    RCCP_CarController vehiclePrefab,
    Vector3 position,
    Quaternion rotation,
    bool registerAsPlayer,
    bool isControllable,
    bool engineRunning
)
ParameterDescription
vehiclePrefabThe vehicle prefab to instantiate
positionWorld position to spawn at
rotationWorld rotation to spawn with
registerAsPlayerRegister as the active player vehicle
isControllableEnable player input
engineRunningStart with engine running

Returns: The spawned RCCP_CarController instance.

RCCP.RegisterPlayerVehicle

Register an existing vehicle as the active player vehicle. The camera and UI will follow this vehicle.


void RCCP.RegisterPlayerVehicle(RCCP_CarController vehicle)
void RCCP.RegisterPlayerVehicle(RCCP_CarController vehicle, bool isControllable)
void RCCP.RegisterPlayerVehicle(RCCP_CarController vehicle, bool isControllable, bool engineState)

RCCP.DeRegisterPlayerVehicle

Remove the current player vehicle registration. Camera and UI disconnect.


void RCCP.DeRegisterPlayerVehicle()

Vehicle Control

RCCP.SetControl

Enable or disable player input on a vehicle.


void RCCP.SetControl(RCCP_CarController vehicle, bool isControllable)

RCCP.SetExternalControl

Flag a vehicle for external (non-player) control. Used by AI and network systems.


void RCCP.SetExternalControl(RCCP_CarController vehicle, bool isExternal)

RCCP.SetEngine

Start or stop a vehicle's engine.


void RCCP.SetEngine(RCCP_CarController vehicle, bool engineState)

RCCP.SetAutomaticGear

Set the transmission mode.


void RCCP.SetAutomaticGear(RCCP_CarController vehicle, bool automatic)
void RCCP.SetAutomaticGear(RCCP_CarController vehicle, RCCP_Gearbox.TransmissionType type)

Vehicle State

Direct Properties

Access vehicle state through the RCCP_CarController instance:


RCCP_CarController vehicle = RCCP_SceneManager.Instance.activePlayerVehicle;

// Speed and movement
float speed = vehicle.speed;                    // km/h
float absSpeed = vehicle.absoluteSpeed;         // absolute km/h
int direction = vehicle.direction;              // 1 = forward, -1 = reverse
bool grounded = vehicle.IsGrounded;             // any wheel touching ground

// Engine
float rpm = vehicle.engineRPM;
bool running = vehicle.engineRunning;
float torque = vehicle.producedEngineTorque;    // Newton-Meters

// Transmission
int gear = vehicle.currentGear;
float gearRatio = vehicle.currentGearRatio;
bool shifting = vehicle.shiftingNow;
bool reversing = vehicle.reversingNow;

// Inputs (vehicle-processed values)
float throttle = vehicle.throttleInput_V;       // 0-1
float brake = vehicle.brakeInput_V;             // 0-1
float steer = vehicle.steerInput_V;             // -1 to 1
float handbrake = vehicle.handbrakeInput_V;     // 0-1

// Lights
bool headlights = vehicle.lowBeamLights;
bool highBeam = vehicle.highBeamLights;
bool leftIndicator = vehicle.indicatorsLeftLights;
bool rightIndicator = vehicle.indicatorsRightLights;

Component Access

Access vehicle subsystems through lazy-loaded properties:


RCCP_Engine engine = vehicle.Engine;
RCCP_Gearbox gearbox = vehicle.Gearbox;
RCCP_Stability stability = vehicle.Stability;
RCCP_Damage damage = vehicle.Damage;
RCCP_WheelCollider[] wheels = vehicle.AllWheelColliders;
RCCP_Axle frontAxle = vehicle.FrontAxle;
RCCP_Axle rearAxle = vehicle.RearAxle;
Rigidbody rb = vehicle.Rigid;

All component properties return null safely if the component is missing.


Behavior System

RCCP.SetBehavior

Switch the global driving behavior preset.


void RCCP.SetBehavior(int behaviorIndex)
void RCCP.SetBehavior(string behaviorName)  // Case-insensitive

RCCP.GetBehaviorIndexByName

Find a behavior preset index by name. Returns -1 if not found.


int RCCP.GetBehaviorIndexByName(string name)

RCCP.GetBehaviorByName

Get the full behavior type object by name. Returns null if not found.


RCCP_Settings.BehaviorType RCCP.GetBehaviorByName(string name)

Transport

RCCP.Transport

Teleport a vehicle to a new position and rotation.


// Teleport the active player vehicle
void RCCP.Transport(Vector3 position, Quaternion rotation)

// Teleport any vehicle
void RCCP.Transport(RCCP_CarController vehicle, Vector3 position, Quaternion rotation, bool resetVelocity)

Repair

RCCP.Repair

Repair all damage on a vehicle.


// Repair the active player vehicle
void RCCP.Repair()

// Repair a specific vehicle
void RCCP.Repair(RCCP_CarController vehicle)

Camera

RCCP.ChangeCamera

Cycle to the next camera mode.


void RCCP.ChangeCamera()

Direct Access


RCCP_Camera camera = RCCP_SceneManager.Instance.activePlayerCamera;
camera.cameraMode = RCCP_Camera.CameraMode.FPS;

Mobile

RCCP.SetMobileController

Set the mobile input method.


void RCCP.SetMobileController(RCCP_Settings.MobileController type)

Options: TouchScreen, Gyro, SteeringWheel, Joystick


Recording and Replay

RCCP.StartStopRecord

Toggle vehicle movement recording.


void RCCP.StartStopRecord(RCCP_CarController vehicle)

RCCP.StartStopReplay

Play back the last recording or a specific clip.


void RCCP.StartStopReplay(RCCP_CarController vehicle)
void RCCP.StartStopReplay(RCCP_CarController vehicle, RCCP_Records.RecordedClip clip)

RCCP.StopRecordReplay

Stop any active recording or replay.


void RCCP.StopRecordReplay(RCCP_CarController vehicle)

World

RCCP.CleanSkidmarks

Remove tire marks from the ground.


void RCCP.CleanSkidmarks()         // Remove all
void RCCP.CleanSkidmarks(int index) // Remove specific layer

Input Override

Override player input to control a vehicle programmatically:


// Create custom inputs
RCCP_Inputs inputs = new RCCP_Inputs();
inputs.throttleInput = 1f;     // Full throttle
inputs.steerInput = -0.5f;     // Half left
inputs.brakeInput = 0f;
inputs.handbrakeInput = 0f;
inputs.nosInput = 0f;
inputs.clutchInput = 0f;

// Apply to vehicle
vehicle.Inputs.OverrideInputs(inputs);

// Restore normal input
vehicle.Inputs.DisableOverrideInputs();

Events

Subscribe to RCCP events for reactive game logic:


// Vehicle lifecycle
RCCP_Events.OnRCCPSpawned += (RCCP_CarController vehicle) => { };
RCCP_Events.OnRCCPAISpawned += (RCCP_CarController vehicle) => { };
RCCP_Events.OnRCCPDestroyed += (RCCP_CarController vehicle) => { };
RCCP_Events.OnRCCPAIDestroyed += (RCCP_CarController vehicle) => { };

// Vehicle changes
RCCP_Events.OnVehicleChanged += () => { };
RCCP_Events.OnVehicleChangedToVehicle += (RCCP_CarController vehicle) => { };

// Collision
RCCP_Events.OnRCCPCollision += (RCCP_CarController vehicle, Collision collision) => { };

// System
RCCP_Events.OnBehaviorChanged += () => { };
RCCP_Events.OnRCCPCameraSpawned += (RCCP_Camera camera) => { };
RCCP_Events.OnRCCPUISpawned += (RCCP_UIManager ui) => { };

// UI notifications
RCCP_Events.OnRCCPUIInformer += (string message) => { };

Common Patterns

Spawn Vehicle and Start Driving


public RCCP_CarController prefab;

void Start() {
    RCCP_CarController car = RCCP.SpawnRCC(
        prefab, transform.position, transform.rotation,
        true, true, true
    );
}

Switch Player Vehicle


void SwitchToVehicle(RCCP_CarController newVehicle) {
    RCCP.RegisterPlayerVehicle(newVehicle, true, true);
}

AI Vehicle With Override Inputs


void ControlVehicleExternally(RCCP_CarController vehicle) {
    RCCP.SetExternalControl(vehicle, true);
    RCCP_Inputs inputs = new RCCP_Inputs();
    inputs.throttleInput = 0.5f;
    inputs.steerInput = CalculateSteeringToTarget();
    vehicle.Inputs.OverrideInputs(inputs);
}

Listen for Collisions


void OnEnable() {
    RCCP_Events.OnRCCPCollision += HandleCollision;
}

void OnDisable() {
    RCCP_Events.OnRCCPCollision -= HandleCollision;
}

void HandleCollision(RCCP_CarController vehicle, Collision col) {
    if (col.relativeVelocity.magnitude > 10f)
        Debug.Log("Hard hit on " + vehicle.name);
}

Read Vehicle Telemetry


void Update() {
    var car = RCCP_SceneManager.Instance.activePlayerVehicle;
    if (car == null) return;

    float speed = car.speed;
    float rpm = car.engineRPM;
    int gear = car.currentGear;
    bool abs = car.Stability != null && car.Stability.ABSEngaged;
}

Next Steps