> For the complete documentation index, see [llms.txt](https://ss3d.gitbook.io/systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ss3d.gitbook.io/systems/gamemodes/adding-objectives.md).

# Adding objectives

This page describes how to add a new objective that can then be added to a game mode.

To add a new gameobject you have to first create a new script in **Assets > Scripts > SS3D > Systems > Gamemodes > Objectives.**

You may copy another objective that is already done to make your life easier, but the rules an objective has to follow are:

* It has to be a child of the **GamemodeObjective** class.
* It has to call the **Succeed** method to be completeable.
* It has to have a **CreateAssetMenu** property above the class.
* It has to be in the **SS3D.Systems.Gamemodes.Objectives** namespac&#x65;**.**

Let's say you wanted to create an objective to picking up a BikeHorn

First you would create a new script that inherits **GamemodeObjective**, let's call it **PickupBikehornObjective**.

You would then have to set up the **CreateAssetMenu** property since the **GamemodeObjective** class is an **ScriptableObject.** you should also put it under the **SS3D.Systems.Gamemodes.Objectives** namespace.

You would then end up with this:

<figure><img src="https://3495811604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F95OhrYYgKj0eUTnfM9sL%2Fuploads%2FhGE4F0b8AY3tBJCj935J%2Fimage.png?alt=media&amp;token=2c6a7a26-3799-45a1-ab0d-179d1cea6461" alt=""><figcaption><p>I named the asset "GetBikeHorn" but it could be anything else, it is also better if you put it under Gamemode/Objectives/ so it shows together with all the other objectives.</p></figcaption></figure>

We now add the **pickedUpItemId** and **pickedUpPlayerCkey** private properties so we can hook them to the **ItemPickedUpEvent** and check if the picked up item was a bikehorn.

<figure><img src="https://3495811604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F95OhrYYgKj0eUTnfM9sL%2Fuploads%2FM3qgR6HFbtnf5PXD9E4X%2Fimage.png?alt=media&amp;token=406e03f1-a928-4c32-9da5-d41de3cef939" alt=""><figcaption></figcaption></figure>

We now have to add an event listener to the **ItemPickedUpEvent**, we do that in the **AddEventListeners** method, we will then hook it to a **HandleItemPickedUpEvent** method.

<figure><img src="https://3495811604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F95OhrYYgKj0eUTnfM9sL%2Fuploads%2FzcrTGNlHZBR9FiYvdklV%2Fimage.png?alt=media&amp;token=07511d72-ecd4-485f-abd7-4cc2e57cc619" alt=""><figcaption><p>Here we hook the HandleItemPickedUpEvent to the ItemPickedUpEvent so the method in our class is called whenever that event is invoked.</p></figcaption></figure>

<figure><img src="https://3495811604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F95OhrYYgKj0eUTnfM9sL%2Fuploads%2FjIqzJI5nqoUTrH9iYtlw%2Fimage.png?alt=media&amp;token=4ee475f0-8fb9-4752-ae51-d8813439e43e" alt=""><figcaption><p>This method first gets the item and player data from the ItemPickedUpEvent, then it checks if the picked up item is a BikeHorn and if the player that picked up the item is the player currently assigned to this objective, if so it sets the pickedUpItemId and pickedUpPlayerCkey variables and calls the FinalizeObjective method.</p></figcaption></figure>

We usually call the FinalizeObjective to conclude an objective, but you could call either Succeed or Fail from any method, but following our practices we will do the check inside FinalizeObjective anyway.

<figure><img src="https://3495811604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F95OhrYYgKj0eUTnfM9sL%2Fuploads%2Fp7ljPBykKtQsbFL2a113%2Fimage.png?alt=media&amp;token=7a7df35e-23dc-471c-aaa1-b05625d0b607" alt=""><figcaption><p>Just to be sure we check if the pickedUpItemId is not BikeHorn or if the player isn't the one assigned to the objective, if either isn't we just return and don't do anything, but, if there are no problems then we call Succeed and finish the objective.</p></figcaption></figure>

Now you just have to create the ScriptableObject, for that we go to the **Assets > Content > Data > Gamemode > Objectives** folder, right-click and go **Create > Gamemode > Objectives > GetBikeHorn.**

Now you just have to set up the properties for the objective as follows:

* Title: What is the title of the objective that will appear in the UI.
* Collaboration Type: if the objective is assigned to a single individual, multiple or if it's a competitve objective, meaning a single players can complete it.
* Alignment Requirement: If Traitors, Crew members, or both can get this objective.
* Min Assignees: Minimun number of players that will be assigned this objective.
* Max Assignees: Maximum number of players that can be assigned this objective.

<figure><img src="https://3495811604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F95OhrYYgKj0eUTnfM9sL%2Fuploads%2FnR1kieF6CEGFmkV3kwvj%2Fimage.png?alt=media&amp;token=0a6f2fba-5e89-4a29-bb77-46dab5bfc037" alt=""><figcaption></figcaption></figure>

Done, now you have succesfully added a new objective to the game!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ss3d.gitbook.io/systems/gamemodes/adding-objectives.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
