Game Creator
  • Welcome to Game Creator!
  • Quickstart
    • Get Started
    • Setup
    • Tutorials
  • Game Creator
    • Game Creator
      • Actions
      • Conditions
      • Triggers
      • Hotspots
      • Characters
        • Player
        • Markers
        • Gestures
        • States
        • Advanced
          • IK in custom Animations
      • Camera
        • Camera Motors
      • Variables
        • Global Variables
        • Local Variables
        • List Variables
    • Systems
      • Localization
      • Event System
      • Timeline
      • UI
      • Module Manager
      • Game Creator Toolbar
      • Pool System
      • Game Creator API
        • Custom Actions
        • Custom Conditions
        • Custom Triggers
        • Custom Hooks
        • Custom Save & Load
        • Variables Access
        • Custom Module
  • Dialogue
    • Dialogue
      • Anatomy
      • Actors
      • Dialogue UI
      • API
  • Inventory
    • Inventory
      • Inventory Window
        • Catalogue
        • Recipes
        • Types
        • Settings
      • Merchants
      • Containers
      • Loot Tables
      • Equip Items
      • Actions
      • Conditions
      • Custom Inventory UI
  • Quests
    • Quests
      • Quests Overview
      • Create Quests
      • Quests UI
        • Custom UI
  • Stats
    • Stats
      • Stats Overview
        • Stat
        • Attributes
        • Status Effects
        • Formulas
        • Stat Modifiers
      • Stats UI
      • Common Use Cases
        • Simple Health Bar
        • Regenerative Mana
        • Poison Status Effect
        • Levels and XP
        • Strength and Armor
        • Lockpicking
  • Behavior
    • Behavior
      • Behavior Graph
        • Nodes
        • Blackboard
      • Perception
  • Shooter
    • Shooter
      • Weapons
      • Ammunition
      • Interaction
      • Examples
        • Example 1 - Get Started
        • Example 2 - Pick Weapons
        • Example 3 - Top Down
        • Example 4 - Side Scroll
        • Example 5 - First Person
        • Example 6 - Combat
      • Advanced
        • Custom Crosshairs
        • Shooter API
  • Melee
    • Melee
      • Weapons
        • Blade Component
      • Shields
      • Melee Clips
      • Combat
  • Traversal
    • Traversal
      • Obstacles
      • Climbables
      • Built-in Elements
  • Annex
    • Roadmap
    • FAQ
Powered by GitBook
On this page
  • Creating and Editing
  • Nested Access
  • Saving Variables
  • Advanced

Was this helpful?

  1. Game Creator
  2. Game Creator
  3. Variables

Local Variables

Store your progress per scene

PreviousGlobal VariablesNextList Variables

Last updated 5 years ago

Was this helpful?

Local Variables are one of the most useful Game Creator tools. They allow to access different variable instances from different game objects but with the same name.

For example, let's say you want to give each character of your game a unique name. You can create a Local Variables component on each one of them and create a local variable called name.

When accessing it, each character will return its own unique name.

Local Variables work pretty much like Global Variables. The difference is that they live inside the scope of a game object, not project wide.

Creating and Editing

To create a local variable you can add the Local Variables component to any game object. Alternatively you can create one using the Game Creator Toolbar option to create a new instance.

Notice there's a UID field at the end of the component. This UID is used by the save-system to keep track of the different variables between play sessions.

Every time you create a Local Variable, a unique UID is generated. You have to bear in mind though that when duplicating a Local Variable, this value will stay the same and two Local Variables will exists with the same UID. In that case, click on the R button to generate a new unique button.

It is specially important that you don't modify the UID after releasing your game. Doing so will reset the player's game progress.

You can also modify the UID value with a more descriptive one, as long as they are unique.

Nested Access

Since version 0.9.7 you can access nested Game Object variables. For example, if a Local Variable A has a reference to another Game Object B that also contains a Local Variable, you can access the Local Variable B by adding a "slash" character between the names of both variables.

  • Game Object 1 has Local Variable "myVariableA" with Game Object 2 as its value

  • Game Object 2 has Local Variable "myVariableB" with an arbitrary value

myVariableA/myVariableB

Accessing via the above name will return the value of the second Local Variable.

Saving Variables

Just like Global Variables, Local Variables have a little checkbox next to its name field. Marking it will tell Game Creator that this variable value must be tracked between play sessions.

Prefabs can't save the value of any type of variable because there can be any number of prefab instances in a scene at any given point.

Advanced

If you are a programmer and want to access the Local Variables API, check out the .

scripting guide documentation