Personal Work
​
Wolf AI
​
-
Wolf AI whose behaviour adapts to different needs.
-
It is controlled by a generic state machine.
-
The needs have a priority order, meaning that the wolf would stop searching for a prey if it gets too tired to continue. In order they are:
-
Energy
-
Thirst
-
Hunger
​
Each need has a value that decreases over time, but they can also be controlled from the inspector.
​
Main States:
-
Idle
-
Search for target (when it needs to fulfill a need)
-
Can search for: Shelter to replenish energy, Water source to replenish thirst, and Prey to replenish hunger.
-
Approach (when target is found)
​
Once the target is reached, it will transition to the appropriate state depending on the target type:
-
Attack for a prey that's still alive. It will be followed by Eat once the prey's health reaches 0.
-
Eat for a prey that's already dead
-
Drink for a water source
-
Rest for a shelter
I'm using models from Malbers Animations that are available on Unity's asset store
Generic State Machine
​
-
State machine that can be used for any type of object and re-used for multiple projects.
-
State class contains methods to manage transitions between the states: EnteringState, LeavingState, and UpdateState. Custom states only have to inherit from this class.
-
Works with the UpdateCaller. Once it's disabled (e.g when the gameObject is destroyed), the UpdateCaller will stop updating it.
​​
Update Caller
​
-
Can be the only script to actually use Unity's Update method, allowing a better control over what's updating every frame, and in which order.
-
Can update generic state machines or objects that implement the IUpdatable interface.
-
Possibility to add an IUpdatable with a higher priority, like a GameManager, so it's Update method is called before the others.
​​