Search Unity

Making NavMeshAgents queue / wait in line

Discussion in 'Navigation' started by jankammerath, Dec 18, 2018.

  1. jankammerath

    jankammerath

    Joined:
    Dec 17, 2018
    Posts:
    1
    Hello everybody,

    I have a couple of NavMeshAgents approaching my desk towards a defined point. As all agents are moving towards the same destination point, but need to wait until the agent before them is finished, each of them needs to wait in line. Before I start writing a massive script in C# I wanted to ask whether there is any best practice for queueing NavMeshAgents?

    Many thanks in advance,

    Jan
     

    Attached Files:

  2. This is a decision making problem, not really navigation. But I would go with something like this:

    - have a blackboard, where you can signal if the desk is occupied or not
    - as soon as an agent arrives to the service point, it flips the signal, when he leaves, it flips again
    - have a point where they will form a queue
    - when the agent goes to the desk, it periodically needs to check if it's occupied or not, when the agent is "close" (it needs tweaking) I would raycast it, so if someone is closer to the service point, the agent knows beforehand (so you can redirect him to the queue)
    - I would really build a FIFO queue, every agent attached to the end and detached from the front and every agent would monitor the one in the front of it. This allows you to develop more life-like behavior (like one agent is slow, one is quickly catch up with the queue or someone is checking their phone so he leaves a gap between him and in the front)
    - when the agent leaves the service area, the front from the queue would get a green light to navigate to the service point
    - for the agents, it's an FSM (simple really)
     
    dadude123 likes this.
  3. a598504775

    a598504775

    Joined:
    Oct 19, 2019
    Posts:
    1
    I get the same question recently. I would like to know if the problem has been solved? Thank you.
     
  4. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    The answer is right above you.
     
    DwinTeimlon likes this.
  5. munaeemm

    munaeemm

    Joined:
    Jul 23, 2022
    Posts:
    3
    have a point where they will form a queue

    That is the main question