TriggerColliderRemovedEvent

Description

If a vehicle detects a collider and that collider is destroyed by another script, the OnTriggerExit method is not automatically triggered. In such cases, this method needs to be manually invoked to remove the obstacle in front of the traffic vehicle.

Declaration

public static void TriggerColliderRemovedEvent(Collider collider)

Parameters

NameDescription

collider

The removed collider.

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);
    }

    public void DestroyObstacle()
    {
        GameObject obstacleToDestroy = GameObject.Find("SomeObstacle");
        Collider collider = obstacleToDestroy.GetComponent<Collider>();
        API.TriggerColliderRemovedEvent(collider);
        Destroy(obstacleToDestroy);
    }
}

Last updated