Scenario: Crafting with capacity limits, animations etc
For now I have a simple BT where the AI is assigned an external BT for whatever job they are assigned to, let's say foraging for food.
I setup a sharedVariable for the job location (gameobject I place in the world).
BT is simple at this point:
What I am trying to do next is fill out the 2 Wait action placedholders with something like:
My best guess is to use the send/receive events? Something like...
Any examples that have this type of two-way communication with game code?
Thanks
For now I have a simple BT where the AI is assigned an external BT for whatever job they are assigned to, let's say foraging for food.
I setup a sharedVariable for the job location (gameobject I place in the world).
BT is simple at this point:
- Seek - sharedVariable "job location"
- Wait - (Simulates animation and AI checking if inventory is full)
- FindNextForagePoint - custom action that finds the next "forage" tag as a gameObject, sets shared variable nextForageItem
- Seek - sharedVariable "next forage item"
- Wait - (again Simulates animation and AI checking if inventory is full)
What I am trying to do next is fill out the 2 Wait action placedholders with something like:
- goes to job location, play animation checking inventory (I'm assuming I'll just use the Unity->Animation actions in BD)
- check code - Is location full? yes/no
- if no, find next forage target and seek
- at next forage target, I need to interact with the resource and reduce it's inventory, which is all handled in code
- if forage target becomes empty, move to next forage target
- etc
My best guess is to use the send/receive events? Something like...
- Get to forage loctation, send event "arrived at resource point", then BD waits for response, likely playing some animation
- in code I receive that event, process resource inventory being depleted over time until zero, then raise event "resource depleted" in the BT
- the BT receives that event and decides how to proceed.
Any examples that have this type of two-way communication with game code?
Thanks