Game Development Reference
In-Depth Information
And finally, to prevent the player from activating the laser prematurely, you will add a flag in the
laser controller.
1.
In the LaserController script, add the following variable:
internal bool activated; // flag to allow laser
In the Update function, change the if(animator) line to
2.
if (animator && activated) { // check for its existance and activation flag first
You can turn the flag on when the hat is opened by an outside source.
In the OpenHat function, add
3.
activated = true;
4.
Save the script.
5.
Click Play, and make sure the hat cannot be opened by the player but opens
when the battery charge gets low.
6.
Save the scene, and open the StartMenu scene.
7.
Play through the game from start to finish.
8.
When you are satisfied with the ensuing chaos, make a final build!
As always, one can continue to think of ways to improve the game, and there are undoubtedly bugs
that will be discovered as the game is tested by a larger number of people, but this last chapter's
additions will be as far as the topic goes. Be sure to follow the topic's thread on the Unity forum
(search the topic's title in the Learning forum) for discussion, errata, tweaks for version changes, and
just to say hi.
Summary
In this final chapter, you had the opportunity to add a bit of extra functionality to the game. An
overhead map, the appearance of the electric slug as a power-up, and a hat-based laser gun
provided the player with some extra options for accomplishing his goal.
The overhead map, a HUD feature, showing the location of the last few zombie bunnies was
implemented with another camera layer. With the help of the Viewport Rect parameters, you learned
how to inset one camera's view into another's without making use of the Pro-only render-to-texture
feature. Making good use of the camera's Culling Mask, you were able to pick and choose what was
shown on the simplified view.
In creating an opportunity for a power-up that extended the life of the battery, you were able bring
the electric slug into the game for a cameo appearance. After experimenting with its speed, you
settled on activating it when the battery reached a critical level.
 
Search WWH ::




Custom Search