# Memories

A **Memory** captures one aspect of a game object's state through its [Remember](remember.md) component. It writes that state during saving and restores it during loading. Add only the independent Memories the object needs; a movable crate may need **Transform** and nothing else.

![Dropdown menu of memories](assets/memories-list.jpg)

## The built-in Memories

| Memory | Captures | Use for |
| :--- | :--- | :--- |
| **Name** | The object's name. | Objects renamed at runtime. |
| **Tag** | Its tag. | Objects whose tag changes to reflect state. |
| **Layer** | Its layer. | Objects that change layer — becoming non-collidable, for instance. |
| **Transform** | Position, rotation and scale. | Anything the player can move. |
| **Light** | The settings of a **Light** component. | Lights that change color, intensity or range. |
| **Disabled** | Whether the object was switched off. | Things hidden or revealed by gameplay. |
| **Destroyed** | Whether the object had been destroyed. | Pickups, breakables, enemies that shouldn't come back. |
| **Local Variable** | The contents of the object's **Local Variable** component. | State such as health or whether a chest is open. |

## Saving Local Variables

You can store state such as a chest's open state, enemy health, or a dialogue choice in [Local Variables](../variables/local-variables.md). Add the **Local Variable** Memory to preserve those values when you save.

!!! example "A chest that stays open"
    1. Add a **Local Variable** component to the chest with an `is-open` boolean.
    2. Add a **Remember** component with the **Local Variable** Memory.

    The **Local Variable** Memory preserves the chest's open state across saving, quitting, and loading. Its display Event reads the restored variable to select the open or closed model.

## Destroyed

**Destroyed** works in the opposite direction from other Memories. Instead of restoring an object's properties, it restores whether the object should exist.

Use it for an enemy destroyed before saving or a pickup removed when collected. Loading then removes that object again instead of leaving its authored copy in the scene.

## Order within the list

The **Remember** component applies Memories in list order. If one Memory depends on a change made by another, drag them into the required order. For example, restoring a parent can affect how a later Memory restores position.

## Memory cost

Each Memory adds data to the save file and work during loading. Review the list as the number of remembered objects grows, and remove Memories the object doesn't need. A **Remember** component starts with four, but your object may require fewer.

## Writing your own

You can write a custom Memory for component state the built-in Memories don't capture. Your class appears alongside them in the dropdown.

See [Custom memories](../../scripting-api/extending/save/memories.md).

## Where to go next

- **[Remember](remember.md)** — configure the component that hosts Memories.
- **[Profiles](profiles.md)** — separate saved state into numbered slots.
- **[Local Variables](../variables/local-variables.md)** — define the per-object state that a Memory preserves.
