D I G T E K

Loading...

Nullam dignissim, ante scelerisque the is euismod fermentum odio sem semper the is erat, a feugiat leo urna eget eros. Duis Aenean a imperdiet risus.

A game engine is basically software that provides many of the basic functions that are commonly used to build a video game. Most game engines allow for rendering either 2D or 3D shapes by importing files generated in a third-party software such as Blender, or 3D Studio Max or Maya, if you can afford them. Another function often found in a game engine is the ability to write software for the game engine to run. Unity 3D allows you to write software to run your game in C#.

3D game engines have a relatively short history in general computing. Their evolution has been hot and fast. Starting around the 1990s, the 486 processor finally made its way into the general populace as a processor fast enough to allow for everyone to play 3D games. Or at least pseudo-3D, 2D images drawn

in the shape of three-dimensional geometry. The technology for true 3D polygons would take a few more years to make it onto the average person’s desktop.

Pseudo-3D was used to describe skewing and scaling flat sprites or 2D images to appear as though they were in 3D space. True vertex transformation wouldn’t appear in popular video game engines on the PC with games such as Quake 1 until 1995. This was greatly with the help of faster and enhanced graphics processors. The modding community took Quake 1 and created many new additions and full conversions.

When powerful graphics processing units (GPUs) were introduced, it opened the floodgates for many more 3D games to make their appearance. At first, these games functioned only on million-dollar computers, but thanks to 3dfx, nVidia, Maxtrox, and ATi in the late 1990s, the GPU quickly took over being a requirement for any 3D game. At that time, id Software, run by John Carmack, quickly came to the forefront of the 3D gaming engine technologies that introduced many concepts such as spline surfaces, complex shadows, and lighting with Quake 2.

Around 1998, Epic Games’ Unreal Engine and Valve Software’s Source Engine took off with the launch of Unreal Tournament and Half-Life. More modding and conversions exploded onto the scene. Many successful game modifications including Counter-Strike would go on to be one of the most played online multiplayer games Valve Software would publish for years to come.

Before the availability of dedicated GPU and cheap RAM, computers didn’t have enough free resources to support a game engine with editing tools. Often the game itself required so much of the computer that there was little room left for any extras, such as particle editors or just-in-time compiling.

The modding community influenced business, making Unreal 2 and Source more modder friendly. Garry’s Mod and Unreal Editor changed how game engines were made by adding tons of user-friendly tools. Many users bought games specifically to “mod,” or modify, and create new games.

It’s no surprise that at this time many game engines would show up on the scene to cater to the modding community and the independent game developer. The large game engines found themselves top heavy by focusing on large publishers. Companies such as RenderWare and Gamebryo found themselves poorly positioned to compete against newcomers who focused on the independent developers such as Unity 3D.

With the independent game developer in mind, many game engines focused on affordability and crossplatform development. Tools such as Game Maker, Unreal Engine, and of course Unity 3D allowed for many more people to learn and build games without the multimillion-dollar investment formerly required for game production.

1.4.3 Why Use Unity 3D to Learn?

Making a game is more fun than making accounting software.

Having fun learning is more important as getting high test scores. After a test, you pretty much forget the anguish of studying all night and what it was for. So there is no reason to make learning menial work because studying should not be boring.

Once learning becomes entertainment, the lessons become something you want to remember. As a fun experience, you remember the experience longer. I’ve found that learning how to write game artificial intelligence (AI) and behavior is the best way to retain programming experience.

Programming lessons are often taught using stiff diagrams and simple math problems with little or no immediate or obvious applicable use. How often have you actually needed to know where trains would meet leaving two different cities at two different speeds? Experience shows that readers lose interest in any example involving grade-point averages or a train leaving from New York.

Unity 3D offers examples by blowing things up. Calculus and vector examples are usually explained using grids and lines. These concepts are lost by abstract pictures that lack meaning or application. In this case, we’ll use math to solve for where a bad guy needs to throw a grenade in order to hit a moving target.

Finally, we’ll end up with both the knowledge that will help build a game and the skills needed to write software outside of Unity 3D. With any luck, we’ll also have fun while learning. Some of these examples may even help with your math classes.

Unity 3D also provides us with a complete set of tools we can use in our code quickly and easily. These tools are a part of the Unity 3D application programming interface (API). The Unity 3D API is filled with useful things such as commonly used routines, data structures, and classes. These parts of the API are often called a library. We’ll learn what all that means in the remaining chapters.

1.4.4 How Does Unity 3D Use C#?

Not that long ago, Unity 3D supported three programming languages. First there was Boo, which was given an accompaniment with JavaScript followed by C#. As of the latest version of Unity 3D, C# is considered the primary, or first-class programming language. Both JavaScript and Boo have been phased out.

In general, C# is gaining more support across many open source projects and has a growing user base. The Dot Net Foundation which maintains .NET Core, is an open source project supported on multiple platforms.

You might be surprised to learn that programming languages have version numbers. With each new version of a language comes new features. As of the writing of this book, Unity 2018 and newer supports. NET 4.7 which is C# version 7.0. What does that mean? It’s not so simple, actually. Microsoft created .NET (dot net): a framework or a standardized environment in which code can accomplish common tasks with fewer commands. Using software without a framework often means reinventing code that’s been written many times. The framework is also intended to be easily extended. Unity 3D includes many game-related additions to help make building games easier.

The progression looks something like this table:

January 2002 C# 1.0 .NET 1.0  
April 2003 C# 1.2 .NET 1.1  
November 2005 C# 2.0 .NET 2.0 Unity 3D 4.1
November 2007 C# 3.0 .NET 3.5  
April 2010 C# 4.0 .NET 4.0 Unity 3D 5.6
August 2012 C# 5.0 .NET 4.5  
July 2015 C# 6.0 .NET 4.6 Unity 3D 2017.1
March 2017 C# 7.0 .NET 4.7 Unity 3D 2018.1
August 2017 C# 7.1 .NET 4.7.1  

As new versions of .NET were introduced, the language that went along with it was also upgraded, though with different version numbers. Confusing? Yes. Unfortunately, to add to the confusion there’s also three versions of .NET that include .NET Standard, .NET Framework, and .NET Core. The differences between these have no effect on what we’ll be learning in this book, so I’ll leave that research up to you to do on your own. For now, we’re not so concerned with the version of either so long as the features we learn about the C# language work within the context of Unity.

C# is used by a large community of general application programmers, not just game engineers. Unity 3D is also a cross-platform game engine, and a developer working on either OSX or Windows can both share and use files for Unity 3D. C# is the same on both Mac and PC as well as Android and iOS for mobile, so there is no concern over what operating system you’re going to use.

1.4.4.1 How to Tell Unity 3D What to Do

Unity 3D and Microsoft Visual Studio are going to be our integrated development environment (IDE). IDEs come in many different forms. Many professional Windows programmers use Visual Studio, and Apple developers usually use Xcode in OSX. Microsoft has also made Visual Studio available for OSX. An IDE provides many tools that make programming easier by highlighting the lines of code and automatically completing many commonly repeated tasks.

When it comes to learning about the nuts and bolts of programming, you’re basically learning about how your computer thinks, or in more general terms, how your computer does what it is told. Somewhere along the way you’ll realize how unintelligent your computer is and how smart good programmers are.

Programming is basically writing detailed instructions on what to do and when. In short, get data then do something with the data. A big part of programming is figuring out where to get information; we’ll call this data management. Then you use logic to determine what to do with the data once you have it. Programming logic is organized into algorithms found in statements organized into functions.

Unity 3D provides tools to move characters and objects with your code. These assets all live in the project directory as separate files or entities that you can control through code. Unity 3D provides scenes to give structure to your assets—3D models particle systems for explosions, fire, and other special effects—and tools to create and edit all these things. It is largely up to you to learn these different systems on your own, but this book covers the code part of things.

Unity doesn’t provide a set of 3D modeling or 2D image editing tools. For this you’ll want to find something like Blender 3D which is free or use another 3D modeling and texturing tools set. You’ll also want to look into Gimp or Dogwaffle to paint 2D images to import into Unity.

Leave a Reply