# ScriptableObjects

## Setup in Unity

1. Create a new scene
2. Create a new GameObject called `Goap`, add the `GoapRunnerBehaviour` to it.

![Goap Runner Behaviour](https://1800565653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-c790b665e0d500ed6a6de8ab7a14a9a6aff29755%2Fgetting_started_goap_runner.png?alt=media)

3. Create a folder called `Configs`.
4. Within the `Configs` folder create a folder called `TargetKeys`. Within this folder press right click `Create > GOAP > Target Key Config`. Call the config `WanderTarget`.
5. Within the `Configs` folder create a folder called `WorldKeys`. Within this folder press right click `Create > GOAP > World Key Config`. Call the config `IsWandering`.
6. Within the `Configs` folder create a folder called `Goals`. Within this folder press right click `Create > GOAP > Goal Config`. Call the config `WanderGoal`.
   1. Select the `WanderGoal` script in the `class` property.
   2. Add a condition to the `conditions` property. Set the `key` to `IsWandering`, the `comparison` to `GreaterThanOrEqual` and the `value` to `1`.

![Wander Goal](https://1800565653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-3ad659d1e7610bac7c7d61493b20a13837c03797%2Fgetting_started_config_wander_goal.png?alt=media)

7. Within the `Configs` folder create a folder called `Actions`. Within this folder press right click `Create > GOAP > Action Config`. Call the config `WanderAction`.
   1. Select the `WanderAction` script in the `class` property.
   2. Set the `target` to `WanderTarget`.
   3. Add an effect to the `effects` property. Set the `key` to `IsWandering`, the `increase` to `true`.

![Wander Action](https://1800565653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-3afdd3e2e54919129422717083866735eed5ffe7%2Fgetting_started_config_wander_action.png?alt=media)

8. Within the `Configs` folder create a folder called `TargetSensors`. Within this folder press right click `Create > GOAP > Target Sensor Config`. Call the config `WanderTargetSensor`.
   1. Select the `WanderTargetSensor` script in the `class` property.
   2. Set the `key` to `WanderTarget`.

![Wander Target Sensor](https://1800565653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-bd68c0cdbe33e460872c0b55e9d5e45709522d84%2Fgetting_started_config_wander_target_sensor.png?alt=media)

9. Within the `Configs` folder create a folder called `Sets`. Within this folder press right click `Create > GOAP > Goap Set Config`. Call the config `GettingStartedSet`.
   1. Add the `WanderGoal` config to the `goals` property.
   2. Add the `WanderAction` config to the `actions` property.
   3. Add the `WanderTargetSensor` config to the `targetSensors` property.

![Getting Started Set](https://1800565653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-65d6972d3c490a564bd918d7ad5f97ee49cf2d74%2Fgetting_started_config_goap_set.png?alt=media)

10. In the scene, add a GameObject called `GoapSet`. Add the `GoapSetBehaviour` to it.
    1. In the `Config` property of the `GoapSetBehaviour` select the `GettingStartedSet` config.
    2. In the `Runner` property of the `GoapSetBehaviour` select the `Goap` GameObject.

![Goap Set](https://1800565653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-1459d6fd0e1978b3f0a2c47a14b18a257cc5b4c2%2Fgetting_started_config_goap_set_go.png?alt=media)

11. Create a sphere `GameObject` called `Agent`. Add the `AgentBehaviour`, `AgentMoveBehaviour` and `AgentBrain` to the `GameObject`.
    1. In the `GoapSetConfig` property of the `AgentBehaviour` select the `GoapSet` GameObject.

![Agent](https://1800565653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-14cacc2deae00c52d45daf8b9c2a818935a44d9e%2Fgetting_started_config_agent.png?alt=media)

12. Run the scene. The agent should move around randomly.
