Remove a specific DriveActions action from a vehicle.
Declaration
public static void RemoveDrivingAction(int vehicleIndex, DriveActions action)
Parameters
Name
Description
vehicleIndex
The index of the vehicle.
action
Action to remove.
Example
using Gley.TrafficSystem;
using UnityEngine;
public class Test : MonoBehaviour
{
//a reference to vehicle pool and player assigned in inspector
public VehiclePool vehiclePool;
public Transform player;
void Start()
{
API.Initialize(player, 20, vehiclePool);
}
private void Update()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
//if 1 is pressed the vehicle will stop
API.AddDrivingAction(0, DriveActions.Stop, true);
}
if(Input.GetKeyDown(KeyCode.Alpha2))
{
// if 2 is pressed the vehicle will continue its previous behavior.
API.RemoveDrivingAction(0, DriveActions.Stop);
}
}
}