I am designing a game in Unity which has NPCs (Non-player controllers). I have worked out the path-finding but I need some help with how to implement tasks. I need the task system to be flexible and allow me to easily add new tasks. I also want to be able to have a task trigger another task.
Example for turning light on:
- When mouse clicked on light switch
- Wait for available/idle NPC
- NPC walks to light switch (Using a walkToPostion(pos) task)
- Light turns on
- NPC is set to available/idle and can perform another task
Another example could be emptying the trash can:
- When trash can is full
- Wait for an available NPC
- NPC walks to trash can (Using a walkToPostion(pos) task)
- Trash can is set to empty
- NPC takes garbage bag outside (Using a walkToPostion(pos) task)
- NPC walks back into house/given position. (Using a walkToPostion(pos) task)
- NPC waits to be given next task.
I haven't done a lot with AI before so some hits on how I could go about implements this would be very helpful.
EDIT: One thing I specifically need help with is performing a task inside a task. How do I pause the TurnOnLight task while the player is doing to WalkToPos task?