In my game, I have a cow NPC, that upon getting hungry will search out grass to eat; problem is, that if the player picks up the grass the cow has selected, or if another cow eats the grass, the cow will still move towards the position of the grass; upon reaching its destination it just stands there.
Option 1
Add to grass boolean variable to tag it either as free or taken
So when cow pick grass it can only look trough grasses? that are not tagged as taken
BUT that will not solve scenario if player gonna cut it
You could check if cow pos is same as target position
And if so and grass don’t exist order cow to pick another grass
OR if target pos and cow pos is the same but cow is not eating grass then search for another free grass
This way player can cut grass and other cow won’t eat each other grass
Option 2
Give cow timers
And make cows check every other sec if grass to which they travel still exist
If yes then keep going
If no then pick another random grass
Combine it with my idea of boolean variable for grass from above and you will get more natural cow AI
Option 3
Instead of cows eating grass that stands out
Create new object in place where cow eat grass which would be dirt circle of ground or something
Like in farming games when you can dig grass to create plot
We do not have grid of dirt plots and on top of it grass
We just have green color as ground
And whenever you dig we create dirt object and then turn it into grass
You could do the same and after some time simply remove that dirt object
And it would look like grass grow back
Link the cow to the grass. When the grass is eaten before deleting it, pick the linked cows and then have them find new grass. This would address the current cow and other cows.
Boolean states can also help keep track of what the cows are doing.