Book Image

Procedural Content Generation for Unity Game Development

By : Ryan Watkins
Book Image

Procedural Content Generation for Unity Game Development

By: Ryan Watkins

Overview of this book

Procedural Content Generation is a process by which game content is developed using computer algorithms, rather than through the manual efforts of game developers. This book teaches readers how to develop algorithms for procedural generation that they can use in their own games. These concepts are put into practice using C# and Unity is used as the game development engine. This book provides the fundamentals of learning and continued learning using PCG. You'll discover the theory of PCG and the mighty Pseudo Random Number Generator. Random numbers such as die rolls and card drafting provide the chance factor that makes games fun and supplies spontaneity. This book also takes you through the full development of a 2D game. Starting with level generation, you'll learn how PCG can make the game environment for you. You'll move into item generation and learn the different techniques to procedurally create game items. Thereafter, you'll be guided through the more abstract PCG areas such as scaling difficulty to the player and even generating music! The book helps you set up systems within your games where algorithms create computationally generated levels, art assets, quests, stories, characters, and weapons; these can substantially reduce the burden of manually creating every aspect of the game. Finally, you'll get to try out your new PCG skills on 3D terrain generation.
Table of Contents (18 chapters)
Procedural Content Generation for Unity Game Development
Credits
Disclaimer
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Usage of PCG


The reasons we might consider using PCG include unique, robustness, adaptability, and size. We might strive for our player to experience the game in their own truly unique play-through. We could use PCG to take the content that we have designed and make truly robust games that would take many hours to explore every inch of. We can make our game adapt to the player in interesting ways such as scaling the difficulty to easier or harder based on the actions of the player.

Size, though, is an interesting benefit to PCG. Well before games played with amazing HD graphics at 60 frames a second, they were mostly text based. Early computer systems were very limited both in processing power and storage memory. One of the earliest occurrences of PCG was in games that procedurally generated levels using ASCII characters. We can see an example of this in the game Rogue developed in the 1980s. We discuss Rogue and the subsequent sub-genre of games Roguelike in later chapters.

PCG was thus a solution, of sorts, to the fact that early computers really had no means to present graphics to the player. Graphics comprise the bulk of a game in terms of size taking a lot of processing power and memory. The procedurally generated ASCII levels of Rogue were calculated instead of being loaded from the file. This meant early computer systems could use memory and processing power as needed instead of needing a lot of memory all at once when you start a predefined game level.

We can also consider size savings in terms of our team as well. A designer/artist typically will need to make every piece of game content by hand. As games get larger, it becomes more difficult to create enough unique content within one game. Games lose their reward factor and players become bored easily when they see continuous repetition of in-game content. We then need to produce more content, which means more designers, artists, and individual assets. PCG helps alleviate this need by taking on some of the burden of producing unique content.

PCG can thus be viewed as a tool for the designer. There is a very creative facet to the idea of PCG. We can design pieces or modules of a whole, like a level or item, and use PCG to put them together in unique and interesting ways. We could also make 3D models, but then, we would have to generate the textures for them. Otherwise, we could generate full levels from scratch and add in some designed props. There are plenty of possibilities to fit the situation or team's needs.

Some of Gearbox Software's Borderlands procedurally generated weapons, each generated from asset modules

You also have a unique opportunity to create games that can expand infinitely (or close to it). We will see this later in the book when we learn how PCG can be used to create a game level that never ends. Are you convinced that PCG is an amazing game development component?