- Creating ELearning Games with Unity
- David Horachek
- 521字
- 2021-07-16 12:22:52
Finding the facts
In this game, the hero (player) plays the park ranger in charge of cleaning up Confederation National Park. In mission one, the park ranger has to find the missing flags for the flag monument and return them to their holders. The user will have to find five of 50 US flags. They will be placed at random locations in the world. The user will have to collect them, read about the associated states' trivia, and then bring the flags back once all the five flags have been found. The game comprises the following components:
FlagLocators
: ThisGameObject
hierarchy contains a set of potential flag locations. From these 10 potential locations, five will be randomly chosen.Terrain
: We introduce the terrain editor in this chapter and create a terrain mesh to replace the ground plane from Chapter 2, Interactive Objects and MissionMgr. As our design requires us to have a park-like setting for our game, the terrain editor is the best candidate for building this in the editor quickly and easily; the alternative is modelling the park in a 3D modelling program such as Maya and then exporting and importing into Unity. By adding grass, mountains, and trees we create a picturesque park that will serve as the backdrop and scene for our first game environment.Monument
: This GameObject hierarchy contains a set of five flagmount locations. These are the places where the flags will be attached once the user finds the missing flags and returns them.MissionMgrHelper
: This helper class allows a GameObject to manipulate the state of an already-existing mission. This is done by associating the script with a Prefab and then instantiating after a user interaction.SetupMissionOne
: To accomplish the objectives of the level, this class installs two missions in theMissionMgr
class that we developed in the previous chapter and also picks the random flags and flag locations for those missions.TriviaCardScript
: This class displays a full screen texture on screen that represents a trivia card for a state. The script adjusts the size and layout of the texture and displays it centered on screen. These cards will appear when the flags are first picked up and when they are selected in the inventory.MonumentMgr
: The gameplay objective of this level is to locate flags and return them to a monument with a number of empty mounting points. This class provides an interface for the monument hierarchy to attach an object (a returned flag) to one of the monument's flagmount points.SimpleDetachScript
: This class detaches the GameObject that it is attached to, from any parent transforms, thereby making its parent the global coordinates. This is necessary for packagingGUITextures
in a Prefab for instancing and then previewing.
The first two collections will be referenced by SetupMissionOne
, which picks the flag locations, picks five Prefabs, and instances them. A number of Prefabs will need to be created as well to facilitate the flow logic across missions. Finally, some systems from Chapter 1, Introduction to E-Learning and the Three Cs of 3D Games, and Chapter 2, Interactive Objects and MissionMgr, will be updated to improve the gameplay.