AddDrivingAction
Description
Declaration
public static void AddDrivingAction(int vehicleIndex, DriveActions action, bool force)Parameters
Name
Description
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);
}
}
}
Last updated