DoNotChangeWaypoint

Description

Forbids a pedestrian to receive another waypoint. Useful for traffic lights.

Declaration

public static void DoNotChangeWaypoint(int pedestrianIndex, bool active)

Parameters

Name
Description

pedestrianIndex

The index of the pedestrian.

active

If true -> pedestrian will not receive another waypoint.

Example

using Gley.PedestrianSystem;
using UnityEngine;
public class Test : MonoBehaviour
{
    // A reference to the pedestrian pool and player assigned in the inspector.
    public PedestrianPool PedestrianPool;
    public Transform Player;

    void Start()
    {
        API.Initialize(Player, 1, PedestrianPool);
    }

    public void CannotPass()
    {
        API.DoNotChangeWaypoint(0, true);
    }

    public void Pass()
    {
        API.DoNotChangeWaypoint(0, false);
    }

    // Used for demonstration purposes.
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            CannotPass();
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            Pass();
        }
    }
}

Last updated