Game Development Reference
In-Depth Information
reloaded (during a restart perhaps), this script will be re-instanced when
_level2 is loaded again.
Congratulations! The logic for configuring the missing references of level 2 on startup
has been completed. Let's move our attention to how the mission 2 logic is actually
set up.
Updating the SetupMission2 script
Prior to integrating the missions together, we developed our game so that mission 1,
mission 2, and mission 3 individually selected five states from a bank of 50. While
this is fine for playing them in isolation, we need to add continuity of the state selec-
tions across all three levels. We will do this by storing the selections when they are
made in level 1, and then by restoring them as level 2 and level 3 are loaded.
1. To begin, load the LEVEL1 scene file. Find the Monument GameObject, and
open the SetupMissionOne script.
2. In the SetupMission() method, on line 65, we find the player GameOb-
ject named either Player or Player1 :
GameObject playerObj = GameObject.Find
("Player1");
if (playerObj == null)
p = GameObject.Find ("Player");
3. If a player can be found, we cache a reference to the PlayerData compon-
ent attached to it:
pd = p.GetComponent<playerData>();
Search WWH ::




Custom Search