- Home /
GOAP - how can you change the state outside of an action?
I know how to make new actions as in having preconditions and effects assigned for each one. But I'm struggling making a hunger thing where outside of the actions there's a normal update with a hunger and sleep meter which are running which when they reach a certain value should give the agent a new state of "tired" or "hungry" and then perform the task.
tl;dr, how can you add an effect/ add a state to the agent outside of an action?
Answer by tanoshimi · Aug 20, 2017 at 09:54 AM
I don't quite understand which bit you're having problems with... it's trivial to create a new action of "cook dinner" or "go to bed" when the necessary preconditions of hunger or tiredness are met. Then you re-run the planner to create a new plan for the agent.
I mean as in lets say I want an action with: the precondition "isTired" , true and has the effect "isTired" , false
in order for isTired to be true I need something like a separate script to "goSleepAction" called something like "sleepTimer" which I want to do something similar to defining sleepTime to 1 then every frame remove it by 0.1 * time.DeltaTime so that after 10 seconds of work the agent is now tired and wants to sleep.
I need to change the state of isTired to true in that sleepTimer script but I can't work out how to change the agents states outside of the GOAPAction class
I just figured out how to do this myself but he is now only doing anything when he can complete both goals in one movement how can I do it so he only needs to do one at a time?
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Calling a function outside the Finite State Machine 0 Answers
Bestpractices for statemachines 0 Answers
Multiple Cars not working 1 Answer
Make player not be seen by AI, when player in foilage and shadows. 1 Answer