Last updated
Last updated
Sensors help the GOAP system understand the current game situation.
There are two main types of sensors: WorldSensor
and TargetSensor
.
Sensors can work in two modes: Global
or Local
.
Global: These sensors give information for all agents. For instance, IsDaytimeSensor
checks if it's day or night for everyone.
Local: These sensors check only when the Planner
runs. They give information for just one agent. For example, ClosestAppleSensor
finds the nearest apple for a specific agent.
WorldSensor
checks the game's situation for an agent. It uses WorldKey
to show each situation. The Planner
uses this to pick the best action.
Examples:
IsHungrySensor
checks if the agent is hungry.
HasAppleSensor
checks if the agent has an apple.
To create a new WorldSensor
, create a new class that inherits from LocalWorldSensorBase
or GlobalWorldSensorBase
and implement its Sense
method.
TargetSensor
finds a position for a TargetKey
. The Planner
uses this to know how far actions are.
There are two kinds of Target
: TransformTarget
and PositionTarget
.
TransformTarget: Use this when the target can move. For example, ClosestEnemySensor
finds a moving enemy.
PositionTarget: Use this for a fixed spot. Like, WanderTargetSensor
finds a random spot that doesn't move.
To create a new TargetSensor
, create a new class that inherits from LocalTargetSensorBase
or GlobalTargetSensorBase
and implement its Sense
method.