# Perpendicularity & Height Off Ground

Perpendiculatity and Height Off Ground (also called ZDepth) is an important consideration when creating custom objects in Enter the Gungeon- most expressly applicable when it comes to creating custom objects for rooms, such as traps or decor.&#x20;

Enter the Gungeon is not a 2D game. In fact, it is secretly rendered in 3D space in order to natively allow complex layering. A laser beam can pass through an enemy, above a table, and behind a pillar without any special rendering code thanks to being rendered in 3D space.

Both Perpendicularity and Height Off Ground are properties of an object's `tk2dSprite` component.

## Perpendicularity

#### What is Perpendicularity?

'Perpendicularity' refers to whether or not a sprite is rendered as perpendicular- that is, standing up straight or laying down flat.

<figure><img src="https://1229800202-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQAkTlyeVttU3CJdmYk%2Fuploads%2FI5h8y9xxSMoJMw8HdC8t%2FSprite-0001.png?alt=media&#x26;token=a5f21be6-2ec6-48bc-8f9a-5a15747d9a33" alt="" width="334"><figcaption></figcaption></figure>

In the above image, you can see that the Sarcophagus is 'Perpendicular' (standing up straight) while the *shadow* of the sarcophagus is laying down flat. In fact, most shadow objects in Enter the Gungeon are not perpendicular.

Rendering a sprite as perpendicular, as in the Sarcophagus example, ensures that whether *other* objects are rendered in front of or behind it depends on where they are standing relative to it. Below, you can see that the player is obscured when standing north of the sarcophagus gameobject, because the sarcophagus sprite is secretly standing up straight.

<figure><img src="https://1229800202-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQAkTlyeVttU3CJdmYk%2Fuploads%2FI1YMybQeblBViqXOeSxG%2Fsarco%20perp.png?alt=media&#x26;token=e112d4d6-262f-4d77-88dd-1c169b4fb01b" alt=""><figcaption><p>Shadow is disabled for clarity</p></figcaption></figure>

Now, we can make the Sarcophagus *not* perpendicular. See below how it is now sitting flat against the floor.

<figure><img src="https://1229800202-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQAkTlyeVttU3CJdmYk%2Fuploads%2FjT3yJx7x0kT3BqeqWHWx%2FSprite-0002.png?alt=media&#x26;token=6448cd12-2b26-4a95-b432-fb83e48dc92f" alt="" width="349"><figcaption><p>Again, Shadow is disabled for clarity</p></figcaption></figure>

Now we can look at how that changes how the sarcophagus is layered relative to the player. The convict looks the same when standing below the sarcophagus, but when moved above, they're still rendered as *above* the sarcophagus, because it is still laying flat against the floor.

<figure><img src="https://1229800202-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQAkTlyeVttU3CJdmYk%2Fuploads%2FHYqfZrhrqtJZmj0nGsKt%2FSprite-0003.png?alt=media&#x26;token=4ec7c590-a608-417b-bcc0-18426acd3441" alt=""><figcaption></figcaption></figure>

With this in mind, the perpendicularity of a sprite should depend on how you want it to appear. Should it be consistently rendered above or behind objects no matter where they stand? Or should the layering depend on orientation?

#### Adjusting Perpendicularity

Changing the perpendicularity of a sprite is extremely simple, as it is controlled by the `IsPerpendicular`  bool on the `tk2dSprite` component of an object. The below code is enough to make the sprite of a hypothetical `thingy` gameObject perpendicular. Making a sprite flat is as easy as setting `IsPerpendicular` false once again.

```csharp
thingy.GetComponent<tk2dSprite>().IsPerpendicular = true;
```

## Height off Ground
