Game Development Reference
In-Depth Information
RoundWatcher roundWatcherComponent = roundWatcherObject.
GetComponent<RoundWatcher>();
// Increase the enemy speed for each round.
walkingSpeed = walkingSpeed * roundWatcherComponent.
currRound;
}
Make sure to also reduce the initial Walking Speed value of the enemy to 0.25, or
else they will get crazy fast very quickly. Also, make a note that after a while, the
enemies will start shooting out of the vortexes so quickly that they can actually get
trapped in the scenery. Challenge yourself to adjust the code to either cap the enemy
speed, make the enemies drop out of the vortexes instead of shooting out at their
current speed, or come up with your own solution. That's the beauty of games such
as these—the solution that you feel is right is most likely the correct one.
Give it a start screen
Finally, to wrap everything up, let's go through implementing a quick, button-based
dialog. We're going to add in a start screen with a simple logo to the game as well as
a start button.
As discussed earlier, using Unity's GUI system is generally not the best option due
to its drawbacks, so we will be using more sprites here. There are two key problems
with Unity's native GUI system. The first is performance—it is very slow compared
to other solutions due to using a lot of render calls. Secondly, it is extraordinarily
time consuming to build a UI with. There is no visual editor, which means you have
to write everything in code; it's like HTML in the early '90s all over again. Many
people, however, do swear by Unity's native GUI, but overall it's not for everyone.
This is exactly why Unity is working on overhauling the entire system with a new
GUI system to be added in a future update to the engine.
Let's create some containers so that we can show only what we want. Create two
empty GameObjects and make them both the children of the Main Camera object.
Name the first one Container - HUD and the second one Container - Start . Set
the position of both of these GameObjects to X: 0 , Y: 0 , Z: 0 to position them at the
center of the camera. Move the Round and Score objects to the project Hierarchy tab
so that they become the children of the Container - HUD object.
Import the Title Screen imagery to the project and set them up as sprites like you
have done before. Place the Title sprite in the Container - Start object, give it a nice
position and scale, and set the Order in Layer field to 100 so that it appears in front
of everything else.
 
Search WWH ::




Custom Search