Custom Vehicle Controller
  • Custom Vehicle Controller
  • Guides
    • Workflow
      • Quick Setup
      • Creating New Parts
      • Modifying Parts
      • Creating Vehicle Parts Presets
      • Customizable Sets and Runtime Parts Change
      • Engine Performance Customization
      • Exposing Current Car Stats
    • API
      • CustomVehicleController
      • VehicleEngineSoundManager
      • RaceManager
      • RacerProgress
      • RaceSpawner
      • CollisionHandler
    • Vehicle Controller Input Provider
      • Input System Example
      • Mobile Input
    • Tips, Warnings and Requiremens
      • Work With Editor
      • Vehicle Set Up
    • AI Setup
      • AI Racer Creation
      • AI Racer Setup
      • AI Chaser Setup
      • Race Creation
      • Race Configuration
      • Race Information
    • Vehicle Damage System
      • Vehicle Damage Controller
      • Collision Area Partitioner
      • Part Damage Handler
      • Vehicle Attachments Aligner
      • Collision Handler
    • Additional Settings
      • Custom Vehicle Controller
      • Car Visuals Essentials
    • Package Settings
      • Assets Save Location
      • Project-Wide Surface Settings
    • Extra
      • Adding Visual Effects
        • Individual Effect Set Up
      • Adding Sound Effects
        • Adding Engine Sound
        • Adding Extra Sound Effects
  • Converting To Other Render Pipelines
    • Convert To Built-in RenderPipeline
    • Convert To HDRP RenderPipeline
Powered by GitBook
On this page
  1. Guides
  2. Workflow

Exposing Current Car Stats

PreviousEngine Performance CustomizationNextAPI

Last updated 10 months ago

CurrentCarStats is a scriptable object that contains information about all the possible vehicle state parameters.

In case you want to expose the current car stats of the vehicle, you can assign a CurrentCarStats scriptable object to the controller.

This gives you the ability to display the info to the player, handle camera movement, visual effects, etc.


Alternatively, if you leave this field empty, an instance of the CurrentCarStats scriptable object will be created in the Awake method and will be used by this controller. You can then get the reference to the CurrentCarStats by calling the "GetCurrentCarStats" method of the CustomVehicleController component in the "Start" or the "Update" methods.


CurrentCarStats instance can be created by RMB -> Create -> CustomVehicleController -> CurrentCarStats


Most of the fields that CurrentCarStats keeps track of are self-explanatory. Here is some explanation about fields that might not be so clear:

Property
Description

SpeedPercent

Current car speed divided by the engine's max speed.

CurrentGear

A char that holds information on what gear the vehicle is currently in. Possible values are any positive integer, "N" for neutral and "R" for reverse.

AccelerationForce

A difference between a vehicle's speed last frame and current speed, a.k.a acceleration.

SidewaysForce

A local velocity of the vehicle in the right direction.

WheelSlipArray

An array of type bool that keeps track of every wheel's forward and sideways slip.

IsCapSlipping

Is there at least 1 wheel that is forward or sideways slipping

TCSworking

If TCS is enabled and the drive wheels are slipping because of excessive torque, TCS will work and lower the amount of torque to reduce the wheelspin. When this happens, the property returns true.