Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Creating E-Learning Games with Unity

You're reading from  Creating E-Learning Games with Unity

Product type Book
Published in Mar 2014
Publisher
ISBN-13 9781849693424
Pages 246 pages
Edition 1st Edition
Languages
Author (1):
David Horachek David Horachek
Profile icon David Horachek

Table of Contents (17) Chapters

Creating E-Learning Games with Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Introduction to E-Learning and the Three Cs of 3D Games 2. Interactive Objects and MissionMgr 3. Mission One – Find the Facts 4. Mission One – Future Proofing the Code 5. User Interfaces in Unity 6. NPCs and Associated Technology 7. Mission Two – Testing a Player's Learning 8. Adding Animations 9. Synthesis of Knowledge 10. An Extensible Game Framework Pattern in Unity Index

Chapter 9. Synthesis of Knowledge

In this chapter, we will develop the third level in our e-learning game. This will be the final level in our game; the purpose of which is to help the user consolidate their learning by synthesizing new knowledge. The objective of this level is for the player, having now been promoted to ranger, to walk around the park tending to the needs of the visitors. The visitors will ask various questions or give hints about what they are thinking; the player needs to use higher-order reasoning to successfully interact with the game NPCs in suggesting an answer that has to do with state trivia. If the player answers correctly, we will reward the player in the game to promote learning.

We will reuse significant portions of technology from the first two missions to develop this chapter. In this chapter, we will cover the following topics:

  • Understanding the mission three GameObjects

  • Applying learning theory to mission three

  • Creating the structure for mission three

  • Modifying...

Understanding the mission three GameObjects


In this level, we will implement a number of GameObjects and update others. Some of the game objects are listed as follows:

  • MissionMgr: This GameObject will be present in this level, but we will not use a new mission to track the level progress. The missionMgr GameObject should still stick around in case we want to add secondary missions or side-quests to the game in the future.

  • Player: The Player GameObject will need to have a working playerData component script attached to it. Since this level is completed upon achieving a certain score, and since scores (along with other statistics) are tracked in this data structure, we are required to implement playerData.

  • LevelLogicObj : The LevelLogicObj GameObject is the main logic object that will track the players' score and the number of points that have been earned in this level, and will dispatch the pass condition pop up at the end of the level, assuming enough points have been acquired.

  • QuizCard :...

Applying learning theory to mission three


The choice of a tourism-themed race against the clock was made to fill a number of e-learning game design requirements shown in the following diagram:

Effective learning requires manipulation of the subject matter at various levels of cognitive complexity. Hence, one powerful way to design mission content for our e-learning game is to deliver content that requires the player to interact with the subject matter in a variety of ways. Bloom's Taxonomy (aptly named after American educational psychologist Benjamin Bloom) gives us a pyramid heuristic that illustrates this concept. Relevant to this text; this taxonomy is a set of descriptive words that may be used to classify the different levels of cognitive complexity at which learning can occur.

Having used remembering as the underlying instructional mode in mission one (find the flags) and applying as the underlying instructional mode in mission two (quiz race), we increase the level of interaction with...

Creating the structure for mission three


To begin, use LEVEL2 as a basis for developing LEVEL3 by performing the following instructions:

  1. Copy and paste TESTBED2, and rename the copy TESTBED3.

  2. Make sure that the _global GameObject from the original stays in the copy and that it is positioned at (0, 0, 0).

  3. Rename the _level2 GameObject _level3.

  4. Under _global, ensure that the player (named Player1), camera (named MainCamera), and Game (named Game) child objects can be found. Also, make sure that a GameObject of type GuiTexture named score is present.

  5. Under _level3, we will add the following level three-specific objects:

    • Terrain

    • setupLevel3

    • Time

    • NpcLocators

    • LevelLogicObj

    • Directional Light

Modifying the terrain

It is not necessary to modify the terrain from LEVEL2 to LEVEL3, but feel free to do so if you wish to add variety. The only constraint is that NpcLocators that you place need to be above the ground as before. This is because the NPCs precisely follow the path formed by the locators.

Adding visitors...

Modifying the pop-up system


You will find three pop ups attached to the MainCamera object from the process of copying LEVEL2. These will need to be renamed and updated.

  1. Rename popup_Level2Start to popup_Level3Start.

  2. Update the text to read You have been promoted to Park Ranger. Walk through the park and help the patrons by answering their questions. You must answer all questions correctly and earn 2500 points to win. Good luck!

  3. Ensure that this GameObject start behavior is enabled by default. The results of the steps performed so far are shown in the following screenshot:

  4. Rename popup_Level2Finish to popup_Level3Finish.

  5. Update the text to read Congratulations! Your state trivia knowledge is great! Your park is a success, and you WIN! Click okay to return to main menu.

  6. Ensure that the GameObject start behavior is disabled by default by unchecking it in the Inspector window.

  7. Rename popup_Level3Repeat to popup_Level3Repeat in the Inspector window.

  8. Update the text to read Level 3. Your knowledge of...

Creating the NpcLocators Prefab


The NpcLocators Prefab will hold a collection of locator GameObjects that the setupLevel3 prefab will use to pick locations for the NPCs. This should be a child of the _level3 object and can be constructed from the FlagLocators GameObject from LEVEL 2.

  1. Locate the FlagLocators objects beneath the hierarchy of the _level3 object.

  2. Rename the object to NpcLocators as shown in the following screenshot:

  3. Feel free to mix up the locations of the objects to various places in the scene; this way, the player will not memorize the locations from LEVEL2. For variety, consider placing some on top of the mountains in the middle or around the periphery of the level.

Creating the CorrectResponse Prefabs


The CorrectResponse Prefabs are the pop ups that will be instantiated from the npcDialog (quiz cards) for LEVEL3. Create these according to the following steps:

  1. Copy and paste the popup_QuizSuccessQuestion Prefab into a new folder in the folder named Chapter 9.

  2. Create 50 unique CorrectResponse cards—one for each state/NPC dialog interaction.

  3. We do not need to pass missionToken into missionMgr when this pop up destructs itself, so ensure that there is no missionToken attached (it will do no harm, but it is redundant).

  4. Modify PopupButtonScript.cs and add an AwardPoints action. Make sure that when the button is clicked on each of these Prefabs, 500 points are awarded to the user. When the button is clicked, we simply find the player class and the playerData component, and then add these values to the score member variable as shown in the following code. Don't forget to add the action to the enumeration at the top of the file:

    // inside Dispatch()
    case(popupAction...

Modifying the quiz cards


The QuizCard pop-up window Prefab is the class that permits user interaction with an NPC; upon selecting the button corresponding to the correct response, the CorrectResponse window pop up will be instantiated.

  1. Copy and paste a QuizCard Prefab from Chapter7 into a new folder in Chapter9. Name the new folder NpcQuestions.

  2. Implement 50 unique NPC Dialog cards based on this Prefab, which in turn is based on the trivia content embedded in the Flag pop ups from LEVEL1; they will form the basis for the dialog in this mission.

  3. Keep the associations to the popup_QuizFailedQuestion Prefab for the incorrect answers on these cards. For the correct selection, instantiate a unique and appropriate CorrectResponse Prefab.

  4. Each QuizCard should have a unique CorrectResponse card. In this way, the player can see a contextually relevant response from you as you reply to the player. This gives an excellent opportunity to reinforce the learning material because it gives you a way to rephrase...

Adding another data condition


Just as we saw in Chapter 7, Mission Two – Testing a Player's Learning, when we created listData npcCondition which wrapped a list of GameObjects used to track racers in the race, we will need to create another type of wrapper in this mission; one for the initial score of the player. We can create this list with the following steps:

  1. Copy and paste listData.cs into the folder named Chapter9. Rename the copy floatData as shown in the following screenshot:

  2. Update the declaration in the script to match the new name of the file.

  3. Replace the list<GameObject> _listData variable with the following line of code:

    public float _floatData;

Congratulations! You have now created a second npcCondition data wrapper. An instance of this will be required by the logic of this level to compute the points scored.

Using the setupLevel3 Prefab


The setupLevel3 Prefab will be activated when the user presses the popup_Level3Start button. It will initialize the NPCs for the level, place them in random locations in the world, and set up the state tracking logic that determines if the player achieves success. Perform the following steps to use the setupLevel3 Prefab:

  1. Locate the Prefab named setupLevel2 beneath _level2, and rename it setupLevel3. Duplicate the SetupMissionTwo script from mission two, and rename the duplicate to SetupMissionThree. Place the duplicate in the folder named Chapter9 to keep your assets organized.

  2. Add an instance of this script to the setupLevel3 object.

  3. Inside MonoDevelop, change the class declaration to SetupMissionThree so that it matches the name of the script as shown in the following code:

    public class SetupMissionThree : MonoBehavior
  4. We will use the same pattern to choose random NPC locators as we did for the QuizNpc locators in mission two. We will remove the CorrectPopups list...

Creating the AddScore condition


The AddScore condition will be used by levelLogicObj to track the points earned in this mission. Once the requisite number of points have been earned, this script will return true. This, in turn, will dispatch the response of showing the Success pop up via the ShowLevel3Results response script. Writing this script requires the following steps to be performed:

  1. Create a new script named condition_scoreAdded. Change the base class from MonoBehavior to npcCondition as done with the other condition classes.

  2. Add an instance of this script to LevelLogicObj.

  3. Drag-and-drop this script instance into the second slot of decisionMgr on LevelLogicObj as shown in the following code:

  4. Inside the script, add an int datatype for scoreAdded; this is the number of points necessary for the condition to return true:

    public int scoreAdd;
  5. Add an npcCondition called initialScore. Drag-and-drop the instance of this script from setupLevel3 (remember the object that first stored the score on...

Creating the ShowLevel3Results response


The ShowLevel3Results class will be used to show the success pop up (and some associated cleanup) if the user achieves enough points. It will be dispatched by npcDecisionMgr of LevelLogicObj in this level. Perform the following steps to create the ShowLevel3Results response:

  1. Create a new npcResponse class named response_ShowLevel3Results. Change the parent class from MonoBehavior to npcResponse.

  2. Open the scene file from the last gameplay level TESTBED1.

  3. Copy the popup_Level1Finished Prefab by pressing Ctrl + C.

  4. Open the scene file from the last gameplay level TESTBED3.

  5. Paste this GameObject beneath the hierarchy of MainCamera. Rename the popup_Level3Finish object as shown in the following code:

  6. Add an instance of the response_ShowLevel3Results script to LevelLogicObj.

  7. Drag-and-drop a reference to this script into the Response field beside condition_addScore in decisionMgr for LevelLogicObj.

  8. Drag-and-drop a reference from popup_Level3Finish (inside the MainCamera...

Creating the Time object


The Time object will implement the game's clock functionality in this level. If the time ever reaches zero, this class will display the mission failed pop up. Recall that the source of the added pressure this time around is the clock ticking down to zero. We want this because a little pressure makes the game fun and encourages cognitive flow. Perform the following steps to create the Time object:

  1. Create a new script named TimeScript.cs. Add an instance of it to a new GameObject of type GUIText. Place GUIText on the left-hand side of the screen opposite the score. Note, this is done by adjusting the PixelOffset field of the GUIText component, and not by moving the transform (this is one of the few exceptions to the rule when placing objects in Unity).

  2. A pixel inset of -60, -20 looks good at a screen resolution of 1024 x 768. Some of the settings for the GUIText component are shown in the following screenshot:

  3. Add the following four variables to the script:

    • public GameObject...

Modifying the LevelLogicObj object


The LevelLogicObj object will track the condition when the player has achieved a high score that is enough to earn the level finished pop up and to win the game. To implement this with the technology we already have, we will perform the following steps:

  1. In decisionMgr of npcScript on LevelLogicObj, set the number of interactions to 2. This is required because the LevelLogicObj object will process two interactions each frame.

  2. Create an instance of a floatData condition on LevelLogicObj. Drag-and-drop this into the first condition. Make sure there is only one instance of this script on this object in the editor.

  3. Create an instance of the condition_addScore condition on LevelLogicObj. Drag-and-drop this into the second condition. Set the scoreAdded variable on the condition to 2500, and drag-and-drop the setupLevel3 object into the initalValue reference to associate the initialValue condition component attached there into this component.

  4. Create an instance of...

Rewarding the player


We know that the more the positive responses and positive reinforcement we give to the player for performing well (showing that the material has been retained), the better will he or she retain and be able to recall it on demand. In this mission, we use a number of reinforcement techniques:

  • The score is central to the player's success in this level. We give the player 500 points for each question that is answered correctly.

  • The player is rewarded for further dialog from the player when he or she gives the correct answer. This further immerses the player with positive feedback and helps solidify a positive response.

  • As with mission two, we make the NPC dance after the player gives a correct response. This is another example of a feel-good moment that helps condition a positive response in the player.

  • Much of this feedback happens inside the Action parameter of the CorrectResponse pop up that is displayed for a particular trivia question, so make sure that you have the following...

Summary


In this chapter, we applied learning theory and applied our existing technology from previous chapters in the development of the final level in our game. We developed the third mission of the three in our game, and by applying Bloom's Taxonomy to our learning outcomes, we developed content that encouraged the user to interact with the content at a high level, thus encouraging learning. This completes the final stage in our e-learning game. In the final chapter, we will tie these three levels together with the rest of the game framework while refactoring some systems during the process.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Creating E-Learning Games with Unity
Published in: Mar 2014 Publisher: ISBN-13: 9781849693424
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}