Game.Prefabs.CarBasePrefab
Assembly: Assembly-CSharp (Game)
Namespace: Game.Prefabs
Type: abstract class
Base: VehiclePrefab
Summary:
Abstract base prefab that contains common configuration for car-type vehicles. Provides basic performance and handling parameters (size class, energy type, top speed, acceleration, braking, turning behavior and handling stiffness). These fields are used by the vehicle simulation, pathfinding and animation systems — modify with care and test in-game for balance and stability.
Fields
-
public SizeClass m_SizeClass
Defines the vehicle's size classification (enum). Affects collision bounds, lane occupation, and interactions with road rules (e.g., small car vs. bus/truck behavior). Set to the appropriate SizeClass to ensure correct lane and parking behavior. -
public EnergyTypes m_EnergyType = EnergyTypes.Fuel
Specifies the vehicle's energy/fuel type (enum). Default is Fuel. Used by systems that model fuel/electric consumption, refueling/charging interactions, and any policy logic that filters vehicles by energy type. -
public float m_MaxSpeed = 200f
Top speed for the vehicle in engine units (game speed units — typically in-game speed units; check other vehicle prefabs in the game for exact interpretation). This value caps simulated velocity and influences route time estimates and overtaking behavior. -
public float m_Acceleration = 5f
Acceleration value used by the vehicle's movement model (speed increase per second in game simulation units). Affects how quickly the vehicle reaches m_MaxSpeed and responsiveness when starting from standstill. -
public float m_Braking = 10f
Braking (deceleration) value used when slowing or stopping (rate of speed reduction per second). Higher values make the vehicle stop more quickly; impacts collision avoidance and following distance behavior. -
public float2 m_Turning = new float2(90f, 15f)
Two-component vector controlling turning characteristics. Typical interpretation: - x (first component): steering responsiveness / angular speed (degrees per second or simulated steering rate).
-
y (second component): turning-related damping or minimum turn responsiveness (lower-level handling parameter). Exact semantics are implementation-specific; compare with other vehicle prefabs to tune expected behavior.
-
public float m_Stiffness = 100f
Handling stiffness parameter that influences lateral response, suspension/steering firmness or how tightly the vehicle follows its intended path. Higher values generally produce snappier, less-corrected steering; lower values produce softer, more drifting behavior.
Properties
- None declared on this type.
All configuration is exposed via public fields. Inheriters may add properties or wrapped accessors if needed.
Constructors
public CarBasePrefab()
Default constructor (implicit). Field initializers provide the defaults shown above. Subclasses commonly set or override these values in their constructors or initialization routines.
Methods
- None declared on this type.
Behavior is implemented in base VehiclePrefab and engine vehicle simulation systems; subclasses typically supply specific mesh/data and may adjust parameters.
Usage Example
using Game.Prefabs;
using Unity.Mathematics;
public class MyElectricCompactCarPrefab : CarBasePrefab
{
public MyElectricCompactCarPrefab()
{
// Assign size and energy type
m_SizeClass = SizeClass.Compact;
m_EnergyType = EnergyTypes.Electric;
// Tune performance
m_MaxSpeed = 140f; // lower top speed for a compact city car
m_Acceleration = 6f; // slightly quicker off the line
m_Braking = 12f; // good braking performance
// Steering: (responsiveness, turn damping)
m_Turning = new float2(100f, 10f);
// Handling stiffness
m_Stiffness = 110f;
}
}
Additional notes: - When modding these fields, test in realistic traffic conditions — changes affect pathfinding time estimates, overtaking behavior, and collisions. - Compare values with existing in-game prefabs (trucks, buses, sports cars) to pick consistent units and ranges. - Related types to inspect: VehiclePrefab (base behavior), SizeClass, EnergyTypes, and any vehicle simulation / physics modules used by the game.