Variable Prompt

🚀 Premium Feature: The Variable Prompt is a premium component that requires an upgraded UFOLab subscription to use in your games.

The Variable Prompt is an advanced component that allows you to collect custom information from players and store it as variables in your game. Think of it as a way to personalize your game experience by asking players to provide specific information that can be used throughout the game - like their name, preferences, or any other custom data you need.

Overview

The Variable Prompt creates a simple form where players can enter text that gets stored as a game variable. This variable can then be used anywhere in your game through text templating, making your content dynamic and personalized. It's perfect for creating engaging, customized experiences where players feel like the game is responding to their input.

Variable Prompt component in the editor showing the userName template

How to Add a Variable Prompt

  1. Open your game in the UFOLab editor

  2. Navigate to the Components section in the component picker

  3. Select Variable Prompt from the advanced components

  4. Drag and drop it onto your scene

Adding Variable Prompt from component picker

Setting Up Your Variable Prompt

Choose Your Variable Template

The Variable Prompt comes with pre-configured templates to make setup easier. Currently available:

User Name Template

  • Variable Name: userName

  • Purpose: Collects the player's name for personalization

  • Use Case: Perfect for creating personalized experiences

Configure Your Settings

Click on your Variable Prompt component to access the configuration options:

Variable Prompt configuration panel

General Settings

Variable Name (Hidden)

  • This is automatically set based on your chosen template

  • For the User Name template, this is set to userName

  • The variable name is how you'll reference this data in your game

Allow Repeated Submit

  • Default: false (recommended)

  • When false: Players can only submit their input once

  • When true: Players can change their input multiple times

  • Best Practice: Keep this false for user names to maintain consistency

Using Variables in Your Game

Once a player submits their information through the Variable Prompt, you can use that data anywhere in your game using text templating.

Text Templating Syntax

Use double curly braces to reference your variables in any text component:

{{variableName}}

User Name Examples

Here are practical examples of how to use the userName variable:

Welcome Messages

Welcome to the adventure, {{userName}}!

Personalized Instructions

{{userName}}, you need to find the hidden treasure in the next room.

Dynamic Dialogue

"Hello {{userName}}! I've been waiting for you. The kingdom needs your help!"

Achievement Messages

Congratulations {{userName}}! You've completed the first level!

Setting Up Text with Variables

  1. Add a Text component to your scene

  2. In the text content, type your message using the variable syntax

  3. The variable will be automatically replaced with the player's input when the game runs

Text component showing variable usage

Actions Setup

Required Actions

When the player submits their information, you need to define what happens next:

  1. Click on your Variable Prompt component to select it

  2. Look for the Actions tab in the properties panel

  3. Set up the "When Submit" action

Action configuration panel
  • Go to another scene - Move the player to the next part of your game

  • Show a welcome message - Display personalized content using the variable

  • Start a timer - Begin a countdown or timed challenge

  • Reveal game elements - Show hidden components or information

  • Play sounds - Trigger audio feedback or background music

Future Use Cases

The Variable Prompt is designed to be extensible. While currently focused on user names, future updates will include additional templates for:

  • Player preferences - Difficulty level, game mode selection

  • Custom data collection - Survey responses, feedback, choices

  • Personalization settings - Avatar names, character customization

  • Educational data - Student information, class details

The component structure is built to easily accommodate these future enhancements while maintaining the same simple setup process.

Integration with Premium Features

Ranking Component (Coming Soon)

The userName variable collected by the Variable Prompt will be used by the upcoming Ranking component, another premium feature that will:

  • Display player names in leaderboards

  • Show personalized achievement lists

  • Create competitive experiences with named participants

This integration makes the Variable Prompt an essential component for creating engaging, competitive game experiences.

Personalized Learning Experiences

Create educational games where students feel personally engaged:

Example Flow:

1. Variable Prompt: "What's your name?"
2. Text: "Welcome {{userName}}! Today we'll learn about..."
3. Personalized feedback throughout the lesson
4. Final message: "Great job {{userName}}! You've mastered the topic!"

Interactive Stories

Make players the protagonist of their own adventure:

Example Flow:

1. Variable Prompt: "What should we call our hero?"
2. Story text: "{{userName}} walked into the mysterious forest..."
3. Character dialogue: "{{userName}}, you must find the ancient artifact!"

Corporate Training

Personalize professional development content:

Example Flow:

1. Variable Prompt: "Enter your employee ID"
2. Training content: "Hello {{userName}}, let's review your training progress..."
3. Personalized completion certificates

If Something's Not Working

My Variable Isn't Showing Up in Text

Check these common issues:

  • Make sure you're using the correct variable name: {{userName}} (case-sensitive)

  • Verify that the player has actually submitted their information through the Variable Prompt

  • Ensure the text component is on the same scene or a later scene (variables persist throughout the game)

  • Check that you've set up the submit action properly

The Variable Shows as Empty

  • Make sure the Variable Prompt has been submitted at least once

  • Verify that the variable name in your text matches exactly: {{userName}}

  • Check that the Variable Prompt is enabled and working properly

Players Can't Submit Their Information

  • Ensure you've set up the "When Submit" action

  • Check that the Variable Prompt component is enabled

  • Verify that "Allow Repeated Submit" is set appropriately for your use case

Creative Tips

Create Variable Chains

Use multiple Variable Prompts to collect different types of information:

Example - Character Creation:

  1. Variable Prompt 1: "What's your hero's name?" → {{userName}}

  2. Text: "The hero, {{userName}}, begins their quest..."

Combine with Other Components

Use variables with other advanced components for rich interactions:

  • Action Scheduler + Variable: "{{userName}}, the timer starts now!"

  • Dialogue + Variable: Character says "Hello {{userName}}!"

  • Quiz + Variable: "{{userName}}, here's your personalized quiz!"

Smart Defaults

Consider what happens if players don't provide information:

  • Use fallback text: "Welcome, {{userName}}!" (shows as "Welcome, !" if empty)

  • Or create conditional logic with other components to handle empty variables


The Variable Prompt is an amazing way to make your games feel personal and engaging. By collecting player information and using it throughout your game, you create experiences that feel tailored to each individual player, making your content more memorable and impactful.

Last updated