How to prevent utility selector from continuously evaluating?

epiphanyatnight

New member
I have a simple sequence like below:
Tree.png

I want the utility selector to only evaluate utilities once, make a decision, and wait until it is explicitly run again. In other words, I want the utility selector to stop evaluating utilities continuously after making a decision. Is this possible?
 
The Utility Selector will evaluate for as long as it is running. It's not possible to limit it to just once, but you could subclass the Utility Selector to provide that functionality.
 
I have a similar problem to this and didn't want to create a whole new thread, but I will if I have to.

I'm pretty much trying to make it so the Utility Selector only runs when one of the NPC's needs goes over a certain value (Needs being what decides what task the Utility Selector will choose). If all needs are below the threshold, then the NPC will just do something similar to wandering around.
So simply put, if hunger, thirst, and sleep are all below 0.5, skip the utility selector and just wander around. Else, perform the tasks needed to get you below the 0.5 threshold.

I've made the conditional for checking the needs and that all works fine.
The problem I am having is that once the Utility Selector starts, it never ends. So if hunger ever goes above 0.5 and triggers the Utility Selector to start, the NPC will never wander again.

I'm sure this is a simple fix by just adding a TaskStatus.Success somewhere in the Utility Selector class, but I have no clue where. There doesn't seem to be much documentation for writing composites, and the only thing I can learn from is the comments left in them.

I see your answer to the OP was to make a subclass. Would the same thing be needed for my case? How would I do it?

I would just have a threshold utility task which always has the value 0.5 so when all other value are below it would trigger that, causing the NPC to wander, but I also want the task to end so I can do things prior to doing the utility selector, like searching for enemies.
 
Last edited:
Sorry for necro'ing this thread, but were you able to create a subclass of Utility Selector that only evaluates the utility once? I'm guessing it would store the child with the highest utility until it restarts.
 
Top