AddVehicle
Description
Declaration
public static void AddVehicle(Vector3 position, VehicleTypes vehicleType)
public static void AddVehicle(Vector3 position, VehicleTypes vehicleType, UnityAction<VehicleComponent, int> completeMethod)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);
}
//hand-picked positions
Vector3 startPosition = new Vector3(0, 0, 0);
public void AddVehicle()
{
//0 - is an example index of the vehicle
API.AddVehicle(startPosition, VehicleTypes.Car, CompleteMethod);
}
private void CompleteMethod(VehicleComponent vehicleScript, int waypointIndex)
{
Debug.Log($"{vehicleScript.name} was instantiated on waypoint {waypointIndex}");
}
}
Last updated