E-Book, Englisch, 398 Seiten
Halpern Developing 2D Games with Unity
1. ed
ISBN: 978-1-4842-3772-4
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Independent Game Programming with C#
E-Book, Englisch, 398 Seiten
ISBN: 978-1-4842-3772-4
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Follow a walkthrough of the Unity Engine and learn important 2D-centric lessons in scripting, working with image assets, animations, cameras, collision detection, and state management. In addition to the fundamentals, you'll learn best practices, helpful game-architectural patterns, and how to customize Unity to suit your needs, all in the context of building a working 2D game.
While many books focus on 3D game creation with Unity, the easiest market for an independent developer to thrive in is 2D games. 2D games are generally cheaper to produce, more feasible for small teams, and more likely to be completed. If you live and breathe games and want to create them then 2D games are a great place to start. By focusing exclusively on 2D games and Unity's ever-expanding 2D workflow, this book gives aspiring independent game developers the tools they need to thrive. Various real-world examples of independent games are used to teach fundamental concepts of developing 2D games in Unity, using the very latest tools in Unity's updated 2D workflow. New all-digital channels for distribution, such as Nintendo eShop, XBox Live Marketplace, the Playstation Store, the App Store, Google Play, itch.io, Steam, and GOG.com have made it easier than ever to discover, buy, and sell games. The golden age of independent gaming is upon us, and there has never been a better time to get creative, roll up your sleeves, and build that game you've always dreamed about. Developing 2D Games with Unity can show you the way.What You'll Learn
Delve deeply into useful 2D topics, such as sprites, tile slicing, and the brand new Tilemap feature.
Build a working 2D RPG-style game as you learn.Construct a flexible and extensible game architecture using Unity-specific tools like Scriptable Objects, Cinemachine, and Prefabs.Take advantage of the streamlined 2D workflow provided by the Unity environment. Deploy games to desktopWho This Book Is For Hobbyists with some knowledge of programming, as well as seasoned programmers interested in learning to make games independent of a major studio.
Jared Halpern is a software developer with over 12 years of experience working in a wide range of technologies. Lately he has specialized in Apple and Unity. Jared has built many iPhone apps over the years, including games, augmented reality, photography, eCommerce, video, and GIF apps. His interests include Swift, Unity, AR, Game Development, and the creative application of these technologies. He has an immense passion for the potential of games as an interactive medium to tell stories and give experiences in ways that other mediums cannot. He currently enjoys working as a freelance software developer.
Autoren/Hrsg.
Weitere Infos & Material
1;Table of Contents;4
2;About the Author;13
3;About the Technical Reviewer;14
4;Acknowledgments;15
5;Preface;16
6;About This Book;18
7;Chapter 1: Games and Game Engines;20
7.1;Game Engines—What Are They?;20
7.1.1;The First Way to Build a House;23
7.1.2;The Second Way to Build a House;23
7.1.3;About the First Approach;24
7.1.4;About the Second Approach;24
7.1.5;In conclusion …;25
7.2;Game Engines Historically;25
7.3;Game Engines Today;27
7.4;The Unity Game Engine;29
7.5;Summary;31
8;Chapter 2: Introduction to Unity;32
8.1;Install Unity;32
8.2;Configure Unity;33
8.2.1;On Disk;34
8.2.2;In the Cloud;34
8.3;The Script Editor: Visual Studio;36
8.4;Navigating the Unity Interface;37
8.5;Understanding the Different Window Views;37
8.6;Configure and Customize the Layout;41
8.7;The Transform Toolset;42
8.8;Handle Position Controls;44
8.9;Play, Pause, and Step Controls;45
8.10;Unity Project Structure;47
8.11;Unity Documentation;48
8.12;Summary;48
9;Chapter 3: Foundations;50
9.1;Game Objects: Our Container Entities;50
9.2;Entity-Component Design;52
9.3;Components: Building Blocks;54
9.4;Sprites;54
9.5;Animations;64
9.5.1;The Animator State Machine;68
9.6;Colliders;73
9.7;The Rigidbody Component;75
9.8;Tags and Layers;76
9.8.1;Tags;76
9.8.2;Layers;77
9.8.3;Sorting Layers;78
9.9;Introducing: Prefabs;82
9.10;Scripts: Logic for Components;84
9.11;State and Animations;94
9.11.1;More State Machines;94
9.11.2;Animation Parameters;97
9.12;Summary;109
10;Chapter 4: World Building;110
10.1;Tilemaps and Tile Palettes;110
10.2;Creating Tile Palettes;112
10.3;Painting with Tile Palettes;115
10.3.1;The Tile Palette;116
10.4;Working with Multiple Tilemaps;120
10.5;Graphics Settings;125
10.6;The Camera;126
10.7;Using Cinemachine;130
10.7.1;Installing Cinemachine in Unity 2017;130
10.7.2;Installing Cinemachine in Unity 2018;131
10.7.3;After Installing Cinemachine;132
10.8;Virtual Cameras;133
10.8.1;Cinemachine Confiner;139
10.9;Stabilization;144
10.10;Materials;148
10.11;Colliders and Tilemaps;149
10.11.1;Tilemap Collider 2D;149
10.11.2;Composite Colliders;152
10.11.3;Editing Physics Shapes;156
10.12;Summary;160
11;Chapter 5: Assembling the Nuts and Bolts;161
11.1;Character Class;161
11.2;Player Class;163
11.3;Focus on Prefabs;165
11.3.1;Create a Coin Prefab;165
11.3.2;Set Up the Circle Collider 2D;166
11.3.3;Set Up a Custom Tag;167
11.4;Layer-Based Collision Detection;169
11.5;Triggers and Scripting;172
11.6;Scriptable Objects;174
11.6.1;Creating a Scriptable Object;175
11.6.2;Build the Consumable Script;179
11.6.3;Assembling Our Item;180
11.6.4;Player Collisions;182
11.6.5;Creating a Heart Power-Up;183
11.6.6;Summary;191
12;Chapter 6: Health and Inventory;192
12.1;Creating a Health Bar;192
12.1.1;Canvas Objects;192
12.1.2;UI Elements;193
12.1.3;Building the Health Bar;193
12.1.4;Anchors;196
12.1.5;Adjusting the Anchor Points;198
12.1.6;UI Image Masks;201
12.1.7;Importing Custom Fonts;205
12.1.8;Adding Hit-Points Text;206
12.1.9;Scripting the Health Bar;209
12.1.10;Scriptable Object: HitPoints;209
12.1.11;Update the Character Script;210
12.1.12;Update the Player Script;211
12.1.13;Create the HealthBar Script;215
12.1.14;Configure the Health Bar Component;219
12.2;Inventory;223
12.2.1;Import the Inventory Slot Image;226
12.2.2;Configure the Inventory Slot;227
12.2.2.1;Configure the ItemImage;227
12.2.2.2;Configure the Background;228
12.2.2.3;Configure the Tray;229
12.2.2.4;Configure QtyText—the Quantity Text;230
12.2.2.5;Create the Prefabs;231
12.2.2.6;Build the Slot Script;232
12.2.3;Create the Inventory Script;235
12.2.3.1;Set-Up Properties;235
12.2.3.2;Instantiate the Slot Prefabs;237
12.2.3.3;Fill in the Start() Method;239
12.2.3.4;The AddItem Method;240
12.2.3.5;Update the Player Script;245
12.2.3.6;One Last Thing …;246
12.2.4;Summary;248
13;Chapter 7: Characters, Coroutines, and Spawn Points;249
13.1;Create a Game Manager;249
13.2;Singletons;250
13.2.1;Creating the Singleton;251
13.2.2;Build a GameManager Prefab;254
13.3;Spawn Points;254
13.3.1;Build a Spawn Point Prefab;257
13.3.2;Configure the Player Spawn Point;261
13.3.3;Spawn the Player;262
13.3.4;In Summary;264
13.3.5;A Spawn Point for Enemies;265
13.4;Camera Manager;267
13.4.1;Using the Camera Manager;269
13.4.2;Character Class Design;272
13.4.3;The Virtual Keyword;272
13.5;The Enemy Class;273
13.5.1;Refactoring;273
13.5.2;The Internal Access Modifier;274
13.6;Coroutines;275
13.6.1;Invoking Coroutines;276
13.6.2;Pausing or “Yielding” Execution;276
13.6.3;A Complete Coroutine;276
13.6.4;Coroutines with Time Intervals;277
13.6.5;The Abstract Keyword;277
13.6.6;Implementing the Enemy Class;279
13.6.7;The DamageCharacter() method;279
13.6.8;ResetCharacter();282
13.6.9;Calling ResetCharacter() in OnEnable();283
13.6.10;KillCharacter();283
13.7;Updating the Player Class;283
13.7.1;Refactoring Prefab Instantiation;285
13.7.2;Review;286
13.7.3;Using What We’ve Built;287
13.7.4;OnCollisionEnter2D;288
13.7.5;OnCollisionExit2D;289
13.7.6;Configure the Enemy Script;290
13.8;Summary;291
14;Chapter 8: Artificial Intelligence and Slingshots;292
14.1;The Wander Algorithm;292
14.1.1;Getting Started;293
14.1.2;Create the Wander Script;294
14.1.3;Wander Variables;295
14.1.4;Build Out Start();297
14.1.5;The Wander Coroutine;298
14.2;Choosing a New Endpoint;300
14.2.1;Angles to Radians to Vectors!;302
14.2.2;Enemy Walk Animation;302
14.2.3;The Move() Coroutine;306
14.2.4;Configure Wander Script;309
14.2.5;OnTriggerEnter2D();310
14.2.6;OnTriggerExit2D();312
14.2.7;Gizmos;314
14.3;Self-Defense;317
14.3.1;Classes Needed;318
14.4;Ammo Class;318
14.4.1;Import the Assets;319
14.4.2;Add Components, Set Layers;319
14.4.3;Update the Layer Collision Matrix;320
14.4.4;Build the Ammo Script;321
14.4.5;Before We Forget ... Make the AmmoObject Prefab;323
14.5;Object Pooling;323
14.6;Building the Weapon Class;325
14.6.1;Stubbing-Out Methods;328
14.6.2;The SpawnAmmo Method;330
14.6.3;The Arc Class and Linear Interpolation;332
14.6.4;Screen Points and World Points;335
14.6.5;The FireAmmo Method;336
14.6.6;Configure the Weapon Script;338
14.6.7;Arcing;339
14.7;Animating the Slingshot;341
14.7.1;Animation and Blend Trees;341
14.8;Blend Trees;342
14.8.1;Clean Up the Animator;343
14.8.2;Build the Walking Blend Tree;344
14.8.3;Layers, All the Way Down;347
14.8.4;A Note About Blend Types;348
14.8.5;Animation Parameters;348
14.8.6;Use the Parameters;350
14.8.7;Ok, but Why ?;352
14.8.8;Loop Time;354
14.8.9;Create the Transitions;354
14.9;Updating the Movement Controller;355
14.9.1;Import the Fight Sprites;357
14.9.2;Create Animation Clips;357
14.9.3;Build the Fighting Blend Tree;359
14.9.4;Exit Time;361
14.9.5;Update the Weapon Class;362
14.9.6;Add the Variables;362
14.9.7;Start();364
14.9.8;Update Update();365
14.9.9;Determining Direction;365
14.9.10;The Slope Method;368
14.9.11;Calculate the Slopes;369
14.9.12;Comparing y-Intercepts;370
14.9.13;HigherThanNegativeSlopeLine();371
14.9.14;The GetQuadrant() method;372
14.9.15;The UpdateState() Method;374
14.10;Flicker When Damaged;377
14.10.1;Update the Player and Enemy Classes;378
14.11;Building for Platforms;379
14.12;Exiting the Game;382
14.13;Summary;382
14.14;What’s Next;383
14.14.1;Communities;383
14.14.2;Learn More;384
14.14.3;Where to Find Help;384
14.14.4;Game Jams;385
14.14.5;News and Articles;386
14.14.6;Games and Assets;386
14.15;Beyond!;386
15;Index;388




