(WIP) Ai Villager work state - finding nearest tree


Still working on the AI villagers basic AI script. Currently working on the AI's work state.

When reaching the work state, the AI now checks if it can work by seeing if it has enough space in inventory to carry more items, if not then it will currently just go back to idle state and stand there.

If it does then it checks if theres an open wood pile to that it can drop off wood at. Now the AI needs to find the closest tree so it can navigate to it and begin cutting it. I was at a crossroads here for performance, I was going to have the AI itself check, but even though this will be a prototype and its such a small version of the game, it could get out of hand fast if we have 10 different AIs checking through ALL the trees in the game.

So essentially I created a Village game object now that will hold all the attributes of the village, including all trees in its given radius from closest to furthest order. This makes sense too cause the AI will want the closest tree to work on so its walking distance to the wood pile isn't too far. This is more performant because all AIs will be referencing one list which is generated by a village, rather than many AIs generating their own list.

Leave a comment

Log in with itch.io to leave a comment.