# IsShared

### Introduction

The IsShared variable determines whether a given variable is shared among all instances of a given Entity. In code, a variable which is marked as **IsShared** is generated as static. A variable which is marked as IsShared has the following characteristics:

* All instances will always have the same value
* The value can be set or read in code even if no instances have been created, or if no instances are available in the current scope
* The value persists even when a Screen is switched or an instance of the entity is destroyed

### Setting IsShared

To set the IsShared property:

1. Expand the Variables tab on the Entity or Screen which contains the variable
2. Select the variable
3. Click the Properties tab
4. Change IsShared to True or False as desired

![Setting IsShared in the Properties tab](/files/vd53DO60smHBZYoVqY0h)

### Accessing a IsShared (static) Variable in Code

Once a variable has been marked as IsShared, it can be accessed from anywhere in code through the type. For example, to access the DebuggingVariables ShowTerrainCollision variable in code, the following snippet could be used:

```csharp
if(Entities.DebuggingVariables.ShowTerrainCollision == true)
{
   // do something to show the terrain collision
}
```

### IsShared and CreatesEvent

Variables which have IsShared set to true generate static events. For more information, see the [CreatesEvent](/flatredball/glue-reference/variables/glue-reference-createsevent.md) page.


---

# 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.flatredball.com/flatredball/glue-reference/variables/glue-reference-isshared.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.
