Exposing Current Car Stats
Last updated
Last updated
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. |