# Block Asset

## Creating new Blocks

**To create a new Block asset:**\
Right-click inside your Project folder → Create > Game Creator > LogicBlock > Block

## **Creating new Lists**

* To create a new **Instruction List**, click **Add Instruction List** inside the Block.
* To create a new **Condition List**, click **Add Condition List** inside the Block.

Each list is a self-contained set of logic that can be triggered, reused, or referenced independently, making your Blocks more modular and easier to manage.

## Recommended Block Setup

Structure your project by creating **Blocks** focused on specific areas of gameplay. This keeps your logic clean, modular, and easy to maintain.

* **Character Block**\
  Contains instructions related to the player or NPC characters, such as:\
  `Jump`, `Deal Damage`, `Pick Up Item`, `Interact`, `Activate Quests`, `Equip Weapons`, and more.
* **AI Block**\
  Handles common AI behaviors like:\
  `Targeting`, `Following`, `Patrolling`, and decision-making logic.
* **GameObject Block**\
  Focuses on world or object-related interactions, such as:\
  `Rotate Pickups`, `Moving Objects`, or control other **non-character** elements.

***

Using dedicated Blocks for each gameplay domain helps you stay organized, reduces duplication, and supports scalable, centralized logic across your project. <br>

***

References

{% hint style="info" %}
**Reference values** are dynamic and must be set via the instruction that calls the list. They are not\
saved directly into the Block asset.
{% endhint %}

References let you configure behavior for each instruction dynamically, without directly editing the list inside the Block. This keeps your logic modular, reusable, and adaptable to different contexts.

***

**Adding a Reference**

1. Open a list inside a Block.
2. Click **Add Reference**.
3. Set a name and choose the appropriate **Reference Type** (e.g., GameObject, Number, Boolean, etc.).
4. Click **Create**.

The reference will appear below the instruction list.\
You can expand it by clicking the reference entry. A **Delete** button is available inside the expanded view if you need to remove it.

***

**Using a Reference in an Instruction**

To make an instruction use a dynamic reference (e.g., setting a GameObject active):

1. Add a **GameObject Reference** to your list.
2. Add a **Set Active** instruction.
3. In the instruction’s **GameObject** field, select:\
   `LogicBlock > Block GameObject Reference`
4. You'll be prompted to specify:
   * The **Block** containing the reference.
   * The **List** inside that Block.
   * The specific **Reference** you created.

> If there's only one reference of that type, it will be auto-selected.\
> If there are multiple, click the field to choose from the available references.

<figure><img src="https://756218607-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv2D32cRkVCHsF9VcmKPA%2Fuploads%2FJpnzMDjGCcxt9eXEGEq1%2FUnity_nF97J5Me6p.png?alt=media&#x26;token=0e99f276-242d-4b98-83f9-8e645830cc4c" alt=""><figcaption></figcaption></figure>

\
Dynamic References work consistently across all supported data types:

* **Items** → use **Block Item Reference**
* **Stats** → use **Block Stat Reference**
* **Booleans, Numbers, Strings**, and other simple types have their own reference selectors available within compatible instructions.

This system ensures your instructions remain **modular and flexible**, enabling centralized logic that adapts to **input-driven variation** without modifying the instruction list itself.

## Buttons

**Play Mode Button**

Each list includes a **Play** button, available while in **Play Mode**, to instantly run the entire instruction list for quick testing.

> **Note:**\
> If the list uses **dynamic references**, those must first be set by running the instruction normally. After that, the Play button will reuse the **last valid reference values**.

**Edit Button**

Click the **Edit** button to expand customization options for the list. You can:

* Rename the list
* Assign a custom icon

The icon selector opens a window with access to Game Creator 2’s icon library and module icons, along with customizable colors. A built-in search field helps you quickly find the icon you need.

**Delete Button**

Click the **Delete** button to remove a list. A confirmation popup appears to prevent accidental deletion.

**Duplicate Button**

Click the **Duplicate** button to create an exact copy of the list.

## Organizing Lists

Each list has a drag handle allowing you to reorder lists inside a Block to keep your workflow neat and intuitive.

## Performance

LogicBlock optimizes editor performance by loading instruction and condition lists only when expanded. This&#x20;keeps the Unity editor fast and responsive, even with many lists in a Block.

## Self and Target

Inside a Block, Self and Target references behave exactly as if the instructions were placed inside the trigger&#x20;itself, preserving expected context seamlessly.

## Sharing Blocks

Blocks can be easily shared between projects by copying their asset files.

To share a Block:

* Locate the Block asset in your Unity project's folder.
* Copy and paste the asset into the same relative folder in your target project.

> **Important**\
> The receiving project must have the **same modules, custom instructions, and hub scripts** installed.\
> If any required components are missing, some instructions may fail to load correctly or be lost entirely.

This method ensures your modular logic can be reused across projects while maintaining flexibility and compatibility.
