Untitled

 avatar
unknown
plain_text
2 months ago
1.2 kB
3
Indexable
IEnumerator PickupBox()
{
    Debug.Log("Car arrived at pickup point.");
    yield return new WaitForSeconds(2); // Wait for 2 seconds at the pickup point.

    Debug.Log("Box picked up.");
    box.SetActive(false); // Make the box disappear.
    boxCarrying = true;

    // Update the state and set path to delivery.
    SetPathToDestination(pickupPoint, deliveryPoint);
    currentState = State.MovingToDelivery;
}

IEnumerator DeliverBox()
{
    Debug.Log("Car arrived at delivery point.");
    yield return new WaitForSeconds(2); // Wait for 2 seconds at the delivery point.

    Debug.Log("Box delivered.");
    box.transform.position = deliveryPoint.transform.position; // Move the box to the delivery point, on the floor.
    box.SetActive(true); // Make the box reappear at the delivery point.
    boxCarrying = false;
    // Add a 2-second delay after the delivery before returning to start.
    yield return new WaitForSeconds(1); // Wait for 1 second after delivering the package.
    // Update the state and set path to return.
    SetPathToDestination(deliveryPoint, returnPoint);
    currentState = State.ReturningToStart;
}
Leave a Comment