Unity in Action: Multiplatform Game Development in C# with Unity 5

Unity in Action: Multiplatform Game Development in C# with Unity 5Reviews
Author: Joe Hocking
Pub Date: 2015
ISBN: 978-1-617292-32-3
Pages: 352
Language: English
Format: PDF/EPUB
Size: 24 Mb

Download

This book helps readers build successful games with the Unity game development platform. You will use the powerful C# language, Unity’s intuitive workflow tools, and a state-of-the-art rendering engine to build and deploy mobile, desktop, and console games. Unity’s single codebase approach minimizes inefficient switching among development tools and concentrates your attention on making great interactive experiences.
Unity in Action teaches you how to write and deploy games. You’ll master the Unity toolset from the ground up, adding the skills you need to go from application coder to game developer. Each sample project illuminates specific Unity features and game development strategies. As you read and practice, you’ll build up a well-rounded skill set for creating graphically driven 2D and 3D game applications.
You’ll need to know how to program, in C# or a similar OO language. No previous Unity experience or game development knowledge is assumed.
What’s Inside

  • Program characters that run, jump, and interact
  • Build code architectures that manage the game’s state
  • Connect your games to the internet to download live data
  • Deploy games to platforms including web and mobile
  • Covers Unity 5
+

It turns out that regardless of whether the Scene view is set to 2D mode, the camera in the game is set independently. This can be handy in many situations so that you can toggle the Scene view back to 3D in order to work on certain effects within the scene. This disconnect does mean that what you see in Unity isn’t necessarily what you see in the game, and it can be easy for beginners to forget this.

The most important camera setting to adjust is Projection. The camera projection is probably already correct because you created the new project in 2D mode, but this is still important to know about and worth double-checking. Select the camera in Hierarchy to show its settings in the Inspector, and then look for the Projection setting (see figure 5.5). For 3D graphics the setting should be Perspective, but for 2D graphics the camera projection should be Orthographic.

What are HTTP requests?

I assume most readers know what HTTP requests are, but here’s a quick primer just in case: HTTP is a communication protocol for sending requests to and receiving responses from web servers. For example, when you click a link on a web page, your browser (the client) sends out a request to a specific address, and then that server responds with the new page. HTTP requests can be set to a variety of methods, in particular either GET or POST to retrieve or to send data.

HTTP requests are reliable, and that’s why the majority of the internet is built around them. The requests themselves, as well as the infrastructure for handling such requests, are designed to be robust and handle a wide range of failures in the network.

In an online game built around HTTP requests, the game developed in Unity is essentially a thick client that communicates with the server in an Ajax style. As a good comparison, imagine how a modern single-page web application works (as opposed to old-school web development based on web pages generated server-side). The familiarity of this approach can be misleading for experienced web developers. Video games often have much more stringent performance requirements than web applications, and these differences can affect design decisions.

Warning
Time scales can be vastly different between web apps and videogames. Half a second can seem like a short wait for updating a website, but pausing even just a fraction of that time can be excruciating in the middle of a high-intensity action game. The concept of “fast” is definitely relative to the situation.

Online games usually connect to a server specifically intended for that game; for learning purposes, however, we’ll connect to some freely available internet data sources, including both weather data and images we can download. The last section of this chapter does require you to set up a custom web server; that section is optional because of that requirement, although I’ll explain an easy way to do it with open-source software.

The plan for this chapter is to go over multiple uses of HTTP requests so that you can learn how they work within Unity: