How I Used the Random Number Variable to Make This Movie Trivia Game
Variables are amongst the most powerful features in Articulate Storyline 360. That’s because they allow you to capture and recall information throughout your project. Using variables, you can show content that’s based on the learner’s choices, activity, or quiz score—just to name a few options. E-learning designers use variables, along with states and triggers, when they need to create more engaging and dynamic learning experiences, like gamified courses or branching exercises that illustrate consequences.
Storyline 360 gives you three variable types to choose from: text, true/false, and number. In this article, we’re going to focus on the number variable.
I like to use number variables because they can be fixed or random values. Having this flexibility opens up lots of creative possibilities. For example, I used the random number variable to create the fun Storyline 360 movie trivia download, below. And I used it in two different ways. Can you spot them? Check it out!
Want to learn more about how I created this project with the random number variable? Keep reading, because I’m going to walk you through the details.
Working with the Random Number Variable
One of the things that makes playing games so much fun is the element of chance—which is the perfect use case for the random number variable. I decided to use the random number variable to assign users a bank of randomly sorted trivia questions. Here’s how I set up the random number variable and then triggered it to direct learners to a random question bank.
Set Up the Random Number Variable
Once I determined the number of question banks I would need for my project (three), I had to set up a random number variable that would draw from a range of numbers between 1 and 3—to reflect the number of question banks in my project.
My trivia question banks were grouped by decade into three individual scenes: the 1970s, 1980s, and 1990s, so I chose to call my new variable “RandomDecade.” I then assigned it a range of numbers from 1 to 3, again to correspond to the number of question banks in my project.
Here’s how it looks in Storyline 360:
With my new “RandomDecade” random number variable ready to go, I needed a way to trigger that variable. Following are the steps for creating those triggers.
Step 1: I inserted a slide that prompts the user to select a game piece or avatar to represent them in the game. Once the user clicks on their selection, it takes them to a layer where their game piece is confirmed and they’re prompted to search for a random question category (i.e., 1970s, 1980s, or 1990s movie trivia).
When the learner clicks the “Search” button, this jumps to a third slide layer where the random number variable is triggered as the layer loads. Here’s how that trigger looks in Storyline 360.
Step 2: With that random number triggered, I needed to direct learners to the question bank scene that corresponds to the value of the random number variable. To do this, I added another layer trigger—but this time with a condition. The trigger I chose is a “Jump to Scene” trigger, set for when the timeline ends. The logic for the condition I assigned to each trigger is as follows:
- Quiz Bank 1 is for 1970s movie trivia, so I wanted to direct learners there when the random number variable equaled 1.
- Quiz Bank 2 is for 1980s movie trivia, so learners should be directed there when the random number variable equaled 2.
- And Quiz Bank 3 is for 1990s movie trivia, so I wanted learners directed there when the random number variable equaled 3.
Here’s how it looked in my project.
Now users will be given one of three randomly selected trivia question banks when they start the game.
Using the Random Number Variable to Simulate Other Players
Another thing that makes games so much fun is the ability to play against other people! (That’s why so many games give you the option to play against a computer player, so you can still have that sense of friendly competition even when you’re playing by yourself.)
To mimic that feeling of friendly competition, I decided to simulate two other “players” in the game. When you start the game you are, by default, Player 1, and whichever game pieces you don’t select are assigned to Players 2 and 3.
The game piece selection on its own creates a pretty cool effect, but to take things a step further, I decided to use the random number variable once again—but this time I used it to make a dynamic quiz results slide for each question bank. I customized these results slides to look a bit like a leaderboard showing a “score” for all three players in the form of an animated bar chart. The bars depicting the scores for Players 2 and 3 (who are simulated players) were randomly changed using—you guessed it—the random number variable!
Here’s how I set that up in Storyline 360.
Step 1: After inserting a graded results slide and removing all the elements, I laid out the vertical scoring bars for my chart and added the game pieces for all three players. At this stage, the results slide looked something like this:
Step 2: I drew a rectangle (located under Shapes on the Insert tab) and added a fill color but no border. I drew my rectangle very narrow—just about five pixels wide. I positioned the rectangle as close to the zero scoring bar as I could. Then, with the rectangle selected, I clicked Edit States and then the New icon. I added four custom states to this rectangle, labeled 25%, 50%, 75%, and 100%. I then stretched the rectangle for each state to its corresponding scoring bar. Here’s how the bar states looked when I was done:
I repeated this process for the other simulated player, changing the color fill.
Step 3: I want to assign a random score to my simulated players, Players 2 and 3. To do that, I set up two new random number variables—Player2Score and Player3Score—with a random number range between 0 and 4. Using some triggers and conditions, a random variable range of 0 to 4 will allow us to change the state of the rectangle bar dynamically, so it shows the simulated players’ scores varying from 0 points to 100 points.
Here’s how my new Player2Score variable looked when I was done:
Step 4: Now it’s trigger time! First, I added a slide trigger to fire off the Player2Score and Player3Score random number variables when the slide loads.
To set this up, I simply added a new trigger to “Adjust variable” and selected Player2Score or Player3Score from the variable dropdown. I then set the value to be a random number between 0 and 4.
Here’s how this looked when I was finished setting up the trigger for Player 2:
And here are both slide triggers in my triggers panel:
Step 5: Now it’s time to add some more slide triggers to change the state of the score bars for Players 2 and 3 to get that dynamic scoring effect I was looking for. To do this, I needed four triggers for each player score bar, as follows:
Using this combo of random number variables to generate scores for the simulated players, and object states, triggers, and conditions, the Player 2 and Player 3 score bars will change their state dynamically, contributing to the illusion of other players in the game.
Putting It All Together
When all is said and done, Player 1 can play again and again, getting up to three different, randomly assigned banks of trivia questions, each with five randomly drawn questions, AND will see totally different scores for the other players at the end of each quiz. Now we’re a little closer to a more game-like experience!
Obviously there are a lot of moving bits and pieces in this project and many different ways you can interpret these ideas and apply them to your own projects.
Following is a quick rundown of a few other Storyline 360 features I used in this project, along with some resources you can refer to for achieving a similar effect.
- The movie-themed background videos and images were straight out of Content Library 360, the ever-growing asset library that’s included with an Articulate 360 subscription. Learn more about the 10.3+ million assets available in Content Library 360 and how to add them to your Storyline 360 projects by checking out this how-to article and video from Arlyn Asch.
- The avatar / game piece selection was accomplished with some triggers to change states. Check out this easy tutorial from Nicole Legault to try this idea out in your projects.
- As I mentioned, I created three movie trivia question banks for this project—one for the 1970s, one for the 1980s, and one for the 1990s. Each bank has 15 questions and is set to draw five random questions. If you’d like to learn more about working with question banks, here’s an article from Nicole Legault that walks through some important considerations.
- Finally, I integrated my quiz result slides into the project just by customizing the features and graphics. You can see more inspiring examples of custom results slides in this popular E-Learning Heroes Challenge and learn how to add and customize a quiz results slide in this step-by-step article.
Have you had a chance to try out the random number variable? Share your thoughts and questions here by leaving a comment. Or, post your own random number variable project downloads and examples in the Building Better Courses forum, where our super-friendly community of e-learning pros love sharing helpful advice and feedback.
Follow us on Twitter and come back to E-Learning Heroes regularly for more helpful advice on everything related to e-learning. If you have any questions, please share them in the comments.