Choice

Choice

Explore another digital game mechanic...CHOICE

 

Build a Decision Tree

 

Choice is in almost all games both desktop and digital  

What step to do next? 

Which direction to go? 

What tool to use? What to wager?

Almost everything come down to player choice!

 

Let's explore the choice mechanic through a simple decision tree

 

A functioning choice tree that can handle different decisions made by the user and present new information based on previous choices.  This allows us to create systems for branching dialogue or "choose your own adventure" style systems.  We will also learn about resetting to our initial state so that we can start over without having to restart the game preview.

 

  1. Load GDevelop and Create a New Project

    1. Open GDevelop and click on "Create a New Project."
    2. Choose any template or select "Empty Project" to start from scratch.
    3. PRO TIP - Add to an existing project or start new to explore mechanics in different contexts
  2. Add Buttons for Your Choices

    1. Click on the "Objects" tab on the right and then click "+ Add a new object"
    2. Choose "Button" from the list of object types
    3. Name your Button "PlayerChoice1" and adjust the text size and font as necessary
    4. Set the initial text to "Go To Town"
    5. Drag and drop the text object onto your scene to place it
    6. Repeat this two more times naming the new buttons "PlayerChoice2" with the initial value of "Run Away" and "PlayerChoice3" with the inital value of "Go To Sleep"
  3. Add Text Objects

    1. Click on the "Objects" tab on the right and then click "+ Add a new object"
    2. Choose "Text" from the list of object types
    3. Name your text object "MainStoryText" and adjust the text size and font as necessary
    4. Drag and drop the text object onto your scene to place it
    5. Do this again naming the text object "LocationText".  Make it smaller and place it in the upper right corner to track the location you currently are at.
    6. PRO TIP: Use text on screen to track values of variables for better and fater testing!
  4. Add Scene Variables

    1. Click the "Project Manager" button in the upper left
    2. Click the three dots next to your main scene and select "Edit scene variables"
    3. Add a new variable called "CurrentChoice" and set the intial value to "start"
  5. Create a Reset Button

    1. Click on the "Objects" tab on the right and then click "+ Add a new object"
    2. Choose "Button" from the list of object types
    3. Name your Button "ResetButton" and adjust the text size and font as necessary
    4. Set the initial text to "Reset Choices"
    5. Drag and drop the button onto your scene to place it
  6. Add Event for Reset Button

    1. Open the Events sheet
    2. Add a new event and click "Add condition"
    3. Select the "ResetButton" and the "is pressed" condition and hit Ok to save
    4. Add a new action and Choose the "PlayerChoice1" button object.  Select the "Label Text" action and set the value to "Go To Town".  Repeat for the other two buttons with "Run Away" and "Go To Sleep" as the text values.
    5. Add another action and select the "MainStoryText" object and the "text" action.  Set the value to "What will you do?"
    6. Add another action and choose the "Change variable value" from the other actions tab.  Select the "CurrentChoice" variable and set it to "start"
    7. Add another action and select the "PlayerChoice1" object and the "Show" action.  Repeat for the other buttons.
  7. Add Events for the Choice Buttons

    1. Open the Events sheet for your scene
    2. Add a new event and a new condition for the event.  Select the "PlayerChoice1" object and the "is clicked" action and hit Ok to save the new condition. 
      • Add another condition checking the variable "CurrentChoice" is set to "start"
    3. Add a new action selecting "MainStoryText" as the object, "text" as the action and set the value to "Welcome to Town!  What Next?". 
      • Add another action with "PlayerChoice1" as the object and "label text" as the action, setting the value to "Visit the Inn". 
      • Repeat this with "PlayerChoice2" and "PlayerChoice3" setting their values to "Visit the Castle" and "Visit the Shoppe". 
      • Add another action to change the varaible "CurrentChoice" to "town".
      • Add a final action choosing "LocationText" as the object, "text" as the action and set the value to our variable CurrentChoice
    4.   Copy and paste the entire block twice and fill out the pasted blocks for "PlayerChoice2" and "PlayerChoice3"
  8. Preview and Test the Scene

    1. Click on the play icon to preview the scene
    2. Try clicking the buttons and test what happens in different cases
    3. PRO TIP - Check your game along the way to ensure things work the way you expect