onVehicleCrashed
Description
Triggered when a vehicle crashes into another object.
Name
Description
vehicleIndex
The index of the vehicle that crashed
obstacleType
The type of obstacle that was hit (Road, StaticObject, DynamicObject, TrafficVehicle, Player, Other).
other
The other collider that was hit.
Example
void Start()
{
API.Initialize(player, 20, vehiclePool);
Events.onVehicleCrashed += VehicleCrashed;
}
private void VehicleCrashed(int vehicleIndex, ObstacleTypes obstacleType, Collider other)
{
switch (obstacleType)
{
case ObstacleTypes.Player:
//player was hit, do something
if(other.name == "Player1")
{
Debug.Log("Player 1 was hit");
}
break;
case ObstacleTypes.DynamicObject:
//a moving object was hit
break;
//Continue for other types of obstacle
}
}
private void OnDestroy()
{
Events.onVehicleCrashed -= VehicleCrashed;
}Last updated