Game.Prefabs.PathfindCarData
Assembly: Assembly-CSharp (game)
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType (struct)
Summary:
Component that groups all configurable pathfinding cost parameters used by car/vehicle pathfinding. This struct is an IComponentData (ECS component) and is intended to be attached to prefab or prototype entities representing vehicle types so the pathfinding system can read the various cost weights (driving, turning, U-turns, lane changes, parking, spawn and forbidden marking) when building routes for cars. The exact numeric details are stored in the PathfindCosts type referenced by each field; these costs influence route selection, avoidance behaviour and whether certain moves are considered viable by the pathfinding jobs.
Fields
-
public PathfindCosts m_DrivingCost
Cost parameters applied for normal driving along a segment (base distance/speed cost). -
public PathfindCosts m_TurningCost
Cost parameters applied when making a (regular) turn at an intersection. -
public PathfindCosts m_UnsafeTurningCost
Cost parameters applied for unsafe turns (e.g., cutting corners, risky maneuvers). -
public PathfindCosts m_UTurnCost
Cost parameters applied when performing a U-turn maneuver. -
public PathfindCosts m_UnsafeUTurnCost
Cost parameters applied for unsafe U-turns (riskier U-turn behavior). -
public PathfindCosts m_CurveAngleCost
Cost parameters that scale with curve angle/sharpness to prefer smoother paths. -
public PathfindCosts m_LaneCrossCost
Cost parameters for crossing lanes (changing lane polarity or overtaking maneuvers). -
public PathfindCosts m_ParkingCost
Cost parameters applied when performing parking-related maneuvers (entering parking spots, stopping). -
public PathfindCosts m_SpawnCost
Cost parameters applied when spawning/entering the road network (e.g., entering from a garage or spawn point). -
public PathfindCosts m_ForbiddenCost
High cost parameters used to mark moves/edges as effectively forbidden or extremely undesirable for pathfinding.
Properties
- None (this type exposes only public fields and implements IComponentData / IQueryTypeParameter).
Constructors
public PathfindCarData()
No explicit constructors are defined in the source; the struct uses the implicit default constructor. Initialize fields explicitly when creating instances.
Methods
- None (no methods are defined on this struct).
Usage Example
// Example: setting up a PathfindCarData component for an entity (e.g., a vehicle prefab)
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Assume `prefabEntity` is an existing entity representing a vehicle prefab.
Entity prefabEntity = /* obtain prefab entity */ default;
var costs = new PathfindCarData
{
// PathfindCosts structure must be initialized according to its definition.
// Replace new PathfindCosts() with appropriate initializers/constructors/fields.
m_DrivingCost = new PathfindCosts(), // set driving weight/value(s)
m_TurningCost = new PathfindCosts(), // set turn penalty(s)
m_UnsafeTurningCost = new PathfindCosts(),// set unsafe-turn penalty(s)
m_UTurnCost = new PathfindCosts(), // set U-turn penalty(s)
m_UnsafeUTurnCost = new PathfindCosts(), // set unsafe U-turn penalty(s)
m_CurveAngleCost = new PathfindCosts(), // set curve-angle scaling
m_LaneCrossCost = new PathfindCosts(), // set lane-cross penalty(s)
m_ParkingCost = new PathfindCosts(), // set parking maneuver cost(s)
m_SpawnCost = new PathfindCosts(), // set spawn/entry cost(s)
m_ForbiddenCost = new PathfindCosts() // set very high cost to mark forbidden moves
};
EntityManager.AddComponentData(prefabEntity, costs);
}
Notes: - The PathfindCosts type defines the actual numeric values/fields used by the pathfinding system; consult its definition to assign meaningful values. - This component is read by the pathfinding systems/jobs (Game.Pathfind) to compute route costs for cars. Adjusting these values alters vehicle routing preference, aggressiveness, lane-changing and avoidance behavior.