Search Unity

Scheduled Task System?

Discussion in 'Navigation' started by PascalTheDog, Oct 17, 2016.

  1. PascalTheDog

    PascalTheDog

    Joined:
    Mar 16, 2015
    Posts:
    86
    Hey,

    Basically, I'm designing a game that takes place in a open town in real time with lots of NPCs that have their own personal plan for the day.

    I'd like this aspect of the game to be malleable. What would be the best way to make sure a NPC reach a certain place at an exact certain time?

    What I've managed to achieve so far is a XML- and NavMesh-based system where every scheduled task is associated with a moment in time. For instance: "Go to work" at 9:30AM.

    The thing is, I obviously only have control over the departure time but not on the arrival time. I can only surmise how much time it will take for a NPC to reach its destination, and that obviously isn't practical for many reasons.

    Would it be possible to provide both a departure time and arrival time, then do some calculus to ensure the NPC reach its destination precisely at the desired arrival time?

    Thanks.
     
  2. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    292
    Well, if you have a distance and a required time, you can calculate the speed you need the character to move at to arrive on time. Alternatively, you can calculate the departure time from the required arrival, distance and the speed.

    I personally would schedule the appointments with a gap in between, so the characters can keep both the departure time of one appointment and the arrival time of the next.
     
    PascalTheDog likes this.
  3. PascalTheDog

    PascalTheDog

    Joined:
    Mar 16, 2015
    Posts:
    86
    Thank you for your response.

    I had thought about this. However, it is possible for the NPCs to encounter obstacles on their way to an appointment (like having to wait at at a traffic light or even simply bumping into other people) which makes matters more complicated. How could I account for such occurrences?

    That's a pretty good idea, indeed. That way, I constantly have access to the relevant variables.