Changing Levels
We now have a more playable game, but it only consists of one level. A game should have a definite end point where you "win" but our game is still lacking that. We will add an end point for the level by using a special trigger script that changes the map. When the player hits the trigger, the level is complete and a new level will be loaded.First, let's pick a new material so we can easily distinguish our trigger object from the rest of the scene. In the asset browser, select the file "Materials\Developer\bluegrid.mat". The draw a box brush at the top of the map, even with the floor. This will be the trigger we use to change the map:
With the new box still selected, select the Scene tab in the side panel to show the scene panel. Select the General tab in the properties editor and set the Name value to "Change Map Trigger". This will make it easy to identify this object in the scene editor. Select the Script tab in the properties editor and press the folder button to open a script file. Choose the file "Scripts\Triggers\TriggerChangeMap.lua" and press the OK button tp attach the script. In the Map Name field, type in "start". This will cause the "start.map" file to load when the trigger is activated.
Now when the player reaches the finishing point of the level, a new level will be loaded automatically. Go ahead and try it!