Need System - IsaacMulcahy/RPG-AI-SYSTEM-WIKI GitHub Wiki
here. This will be kept for a while and will eventually be removed.
This wiki has now moved toOverview
The Need System is an adaptable system which allows for visual scripting of AI behavior tailored towards presenting real world needs and requirements.
How to Create
Creation is done using the Flowchart Editor which is a visual node based system of creating the data required. This can then be imported in by using the Manager.
Tick
The tick rate is based on delta time and has a random range multiplier of 0.75-1.25 applied. This gives small variations and provides a better simulation meaning ##NPCs## needs don't work in a clockwork fashion.
Objects
Need
The overall name of the need the NPC requires. It contains the minimum and max values of the Need along with a graph representing the global weighting over time.
Method
A way of achieving a goal, having more than one of these allow for different ways of achieving the same results. This level allows for added robustness in the system. This also allows for setting the 'affect' of completing the need in this manner which is added on after the final Action is successful.
Action
A predefined explicit set of functions that make the NPC perform actions in the scene (e.g., find something, go somewhere, pick up Item etc).
Set Item in Use: Used for setting the item in use
No Reset of Item in Use: Allows for the item to be carried over as in use for other actions, a following action show use the 'Set Item in Use'to reset the item to not in use
Update Each Loop: This is useful for moving objects, with this selected each game loop the NPC will recalculate where it is heading. This should only be used if needed.
How these are applied
The Needs are used to setup up the character on creation of the NPC and are automatically transferred to another object which is used to represent the state of that Need at runtime providing an easy to look up global weighting and the current value.
A Need becomes an candidate of being the next action when a weighting is above 15% and is the highest out of all other Needs. A Method is then selected based on iterator on use and requirements being met.
However on a Action failing this will cause the Method to fail too. When this happens the next Method will be attempted and the NPC will keep trying until either a Method is successful or all Methods fail. When all Methods then the remaining Tasks for this Duty will be skipped and the next Duty will be attempted.
When are Requirements Applied
Requirements for the Method are only applied on entering of that node.
With Action the Requirements are performed after the Action has been successful and holds the return to the Controller off from being successful until it has been completed.
WARNING ON Unity Version 2022.3.5 the requirement widgets cannot open, to fix follow this
What happens on failures with default Iterators
Images are included to try improve readability, green are successful or newly started, red are failed nodes.
Methods
If a method fails (caused by an action within it failing) and there is another method belonging to the current task then the next method will be tried until successful or all methods have failed.
Actions
If an action fails then the rest of the actions belonging to the method will be skipped and the method will automatically be failed.