# Rules

<figure><img src="/files/n7PWr6T5d3xHTOkP1EAa" 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
