> For the complete documentation index, see [llms.txt](https://docs.gmetri.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gmetri.com/metaverse/build/rules.md).

# Rules

Use Rules to specify how viewers interact with your Metaverse

<figure><img src="https://2186043722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mgll1jjQMRTVj7p6n7g%2Fuploads%2FiERlzjiICESOHuYLwtVq%2Fimage.png?alt=media&amp;token=ca1349e3-8327-4a1a-97eb-12384133fe00" alt=""><figcaption><p>Rules</p></figcaption></figure>

Rules are the building blocks of interactivity in your experience.

{% hint style="info" %}
GMetri uses rules in the form of simple sentences. Like\ <mark style="color:green;">`When polygon is clicked`</mark>`,`` `<mark style="color:blue;">`Then video should disappear`</mark>
{% endhint %}

Rules are always of the form: <mark style="color:green;">**When Something Happens**</mark>**,&#x20;**<mark style="color:blue;">**Then Do Something**</mark>

You can combine multiple *When Events* using `AND` or `OR` highlighted above. You can also combine multiple *Then Actions*. Click on "+Add an Action" to add *Then Actions*, Click on "Add an Event" to add *When Events*.

## Example: Viewer Rules

Using a "When Rule", you can detect when a viewer **enters a zone**.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mgll1jjQMRTVj7p6n7g%2Fuploads%2F8DaNgHZKWvd43kXyC9QI%2Fimage.png?alt=media&#x26;token=10ff3d30-8f1e-43a0-8b87-69508d971332" alt=""><figcaption><p>Viewr Rules</p></figcaption></figure>

Also, using a "Then Rule" you can make the Viewer do the following:

* **Teleport** to another scene, object, or zone.
* **Change the scene** to a different one within the experience.
* **Direct** the viewer to a specific object or element.

## More About Rules

* [Shared Rules](/metaverse/build/rules/shared-rules.md)
* [How Rules Work](/metaverse/build/rules/how-rules-work.md)
* [Number Variable Rules](/metaverse/build/rules/number-variable-rules.md)
* [String Variable Rules](/metaverse/build/rules/string-variable-rules.md)
* [Boolean Variable Rules](/metaverse/build/rules/boolean-variable-rules.md)

## Also Read

* [String Substitution](/metaverse/build/variables/string-substitution.md)
* [Zones](/metaverse/build/scenes/3d-scene/zones.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gmetri.com/metaverse/build/rules.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
