Vehicle Crash
Description
Declaration
public delegate void VehicleCrash(int vehicleIndex, ObstacleTypes obstacleType, Collider other);Parameters
Name
Description
Set Method
public static void SetVehicleCrash(VehicleCrash vehicleCrashDelegate)Example
using Gley.TrafficSystem;
using UnityEngine;
public class Test : MonoBehaviour
{
private void Start()
{
Delegates.SetVehicleCrash(MyVehicleCrashBehaviour);
}
public static void MyVehicleCrashBehaviour(int vehicleIndex, ObstacleTypes obstacleType, Collider other)
{
switch (obstacleType)
{
case ObstacleTypes.Player:
//stop
API.AddDrivingAction(vehicleIndex, DriveActions.StopTemp, false);
break;
case ObstacleTypes.Road:
//ignore
break;
case ObstacleTypes.TrafficVehicle:
//do some special action
API.AddDrivingAction(vehicleIndex, SomeComplexSction(vehicleIndex, other), false);
break;
default:
//by default stop
API.AddDrivingAction(vehicleIndex, DriveActions.StopTemp, false);
break;
}
}
}Last updated