Designed for beginners with no knowledge or experience in game development or programming, this book teaches the essentials of the Unity game engine, the C# programming language, and the art of object-oriented programming. New concepts are not only explained, but thoroughly demonstrated. Starting with an introduction to Unity, you'll learn about scenes, GameObjects, prefabs, components, and how to use the various windows to interact with the engine. You'll then dive into the fundamentals of programming by reviewing syntax rules, formatting, methods, variables, objects and types, classes, and inheritance, all while getting your hands dirty writing and testing code yourself. Later, the book explains how to expose script data in the Inspector and the basics of Unity’s serialization system. This carefully crafted work guides you through the planning and development of bare bones, simple game projects designed to exercise programming concepts while keeping less relevant interruptions out of the way, allowing you to focus on the implementation of game mechanics first and foremost. Through these example projects, the book teaches input handling, rigidbodies, colliders, cameras, prefab instantiation, scene loading, user interface design and coding, and more. By the end, you'll have built a solid foundation in programming that will pave your way forward in understanding core C# syntax and fundamentals of object-oriented programming―not just what to type but why it's typed and what it’s really doing. Game Programming with Unity and C# will send you on your way to becoming comfortable with the Unity game engine and its documentation and how to independently seek further information on yet-untouched concepts and challenges. What You'll Learn Understand the fundamentals of object-oriented computer programming, including topics specifically relevant for games. Leverage beginner-to-intermediate-level skills of the C# programming language and its syntax. Review all major component types of the Unity game engine: colliders and rigidbodies, lights, cameras, scripts, etc. Use essential knowledge of the Unity game engine and its features to balance gameplay mechanics for making interesting experiences. Who This Book Is For Beginners who have no prior experience in programming or game development who would like to learn with a solid foundation that prepares them to further develop their skills. Table of Contents About the Author About the Technical Reviewer Introduction Chapter 1: Installation and Setup Installing Unity Installing Our Code Editor Creating a Project Summary Chapter 2: Unity Basics Windows Project Window Scene Window Hierarchy Window Inspector Window Components Adding GameObjects Summary Chapter 3: Manipulating the Scene Transform Tools Positions and Axes Making a Floor Scale and Unit Measurements Summary Chapter 4: Parents and Their Children Child GameObjects World vs. Local Coordinates A Simple Building Pivot Points Summary Chapter 5: Prefabs Making and Placing Prefabs Editing Prefabs Overriding Values Nested Prefabs Prefab Variants Summary Chapter 6: Programming Primer Programming Languages and Syntax What Code Does Strong vs. Weak Typing File-Type Extensions Scripts Summary Chapter 7: Code Blocks and Methods Statements and Semicolons Code Blocks Comments Methods Calling Methods Basic Data Types Returning Values with Methods Declaring Methods Operators Summary Chapter 8: Conditions The “if” Block Overloads Enums The “else” Block The “else if” Block Operators for Conditions Equality Operators Greater Than and Less Than Or And Summary Chapter 9: Working with Objects Classes Variables Accessing Class Members Instance Methods Declaring Constructors Using the Constructor Static Members Summary Chapter 10: Working with Scripts Usings and Namespaces Script Class Rotating a Transform Frames and Seconds Attributes Summary Chapter 11: Inheritance Inheritance in Action: RPG Items Declaring Our Classes Constructor Chaining Subtypes and Casting Number Value Types Type Checking Virtual Methods Summary Chapter 12: Debugging Setting Up the Debugger Breakpoints Using Unity’s Documentation Summary Part I: Obstacle Course Chapter 13: Obstacle Course Design and Outline Gameplay Overview Technical Overview Player Controls Death and Respawn Levels Level Selection Obstacles Project Setup Summary Chapter 14: Player Movement Player Setup Materials and Colors Declaring Our Variables Properties Tracking the Velocity Applying the Movement Summary Chapter 15: Death and Respawning Enabling and Disabling Death Method Respawn Method Summary Chapter 16: Basic Hazards Collision Detection Hazard Script Projectile Script Shooting Script Summary Chapter 17: Walls and Goals Walls Goals Build Settings for Scenes Summary Chapter 18: Patrolling Hazards Resembling a Patrol Point Arrays Setting Up Patrol Points Detecting Patrol Points The “for” Loop Sorting Patrol Points Moving the Patroller Summary Chapter 19: Wandering Hazards Wander Regions A Basic Editor Extension Editor Scripts Custom Inspectors Accessing the Inspector Target Drawing to the Scene Wanderer Setup Wanderer Script Handling the State Reacting to the State Summary Chapter 20: Dashing Dashing Variables Dashing Method Final Touches Dash Cooldown Summary Chapter 21: Designing Levels Prefabs and Variants Making Levels Adding Walls Level View Camera Summary Chapter 22: Menus and UI Scene Flow Level Selection Script Summary Chapter 23: In-Game Pause Menu Freezing Time Summary Chapter 24: Spike Traps Designing the Trap Raising and Lowering Writing the Script Adding Collisions Summary Chapter 25: Obstacle Course Conclusion Building the Project Player Settings Recap Additional Features Summary Part II: Tower Defense Chapter 26: Tower Defense Design and Outline Gameplay Overview Technical Overview Project Setup Summary Chapter 27: Camera Movement Setting Up Arrow Key Movement Applying Movement Mouse Dragging Zooming Summary Chapter 28: Enemies, Towers, and Projectiles Layers and Physics Basic Enemies Projectiles Targeters Towers Arrow Towers Summary Chapter 29: Build Mode UI Basics The RectTransform Building Our UI Events Setting Up Build Mode Logic The Dictionary OnClick Event Methods Summary Chapter 30: Play Mode Spawn and Leak Points Locking the Play Button Pathfinding Setup Finding a Path Play Mode Setup Spawning Enemies Enemy Movement Summary Chapter 31: More Tower Types Arcing Projectiles Cannon Tower Hot Plates Barricades Summary Chapter 32: Tower Defense Conclusion Inheritance UI Raycasting Pathfinding Additional Features Health Bars Types for Armor and Damage More Complex Pathing Range Indicators Upgrading Towers Summary Part III: Physics Playground Chapter 33: Physics Playground Design and Outline Feature Outline Camera Player Movement Pushing and Pulling Moving Platforms Swings Force Fields and Jump Pads Project Setup Summary Chapter 34: Mouse-Aimed Camera Player Setup How It Works Script Setup Hotkeys Mouse Input First-Person Mode Third-Person Mode Testing Summary Chapter 35: Advanced 3D Movement How It Works Player Script Movement Velocity Applying Movement Losing Velocity Gravity and Jumping Summary Chapter 36: Wall Jumping Variables Detecting Walls Performing the Jump Summary Chapter 37: Pulling and Pushing Script Setup FixedUpdate Target Detection Pulling and Pushing Cursor Drawing Summary Chapter 38: Moving Platforms Scene Setup Platform Movement Player Platforming Summary Chapter 39: Joints and Swings Swing Setup Connecting the Joints Finishing Touches Summary Chapter 40: Force Fields and Jump Pads Script Setup Force Field Setup Adding Velocity to the Player Applying Forces Summary Chapter 41: Conclusion Physics Playground Recap Further Learning for Unity The Asset Store Terrains Coroutines Script Execution Order Further Learning for C# Delegates Documentation Comments Exceptions Advanced C# Operator Overloading Conversions Generic Types Structs Summary Index designed For Beginners With No Knowledge Or Experience In Game Development Or Programming, This Book Teaches The Essentials Of The Unity Game Engine,the C# Programming Language, And The Art Of Object-oriented Programming. Aiming To Be Prolific With Examples, New Concepts Are Not Only Explained, But Thoroughly Demonstrated. Starting With An Introduction To Unity, You'll Learn About Scenes, Gameobjects, Prefabs, Components, And How To Use The Various Windows To Interact With The Engine. You'll Then Dive Into The Fundamentals Of Programming By Reviewing Syntax Rules, Formatting, Methods, Variables, Objects And Types, Classes, And Inheritance, All While Getting Your Hands Dirty Writing And Testing Code Yourself. Later, The Book Explains How To Expose Script Data In The Inspector And The Basics Of Unity’s Serialization System. This Carefully Crafted Work Guides You Through The Planning And Development Of Bare Bones, Simple Game Projects Designed To Exercise Programming Concepts While Keeping Less Relevant Interruptions Out Of The Way, Allowing You To Focus On The Implementation Of Game Mechanics First And Foremost. Through These Example Projects, The Book Teaches Input Handling, Rigidbodies, Colliders, Cameras, Prefab Instantiation, Scene Loading, User Interface Design And Coding, And More. By The End, You'll Have Built A Solid Foundation In Programming That Will Pave Your Way Forward In Understanding Core C# Syntax And Fundamentals Of Object-oriented Programming—not Just What To Type But Why It's Typed And What It’s Really Doing. Game Programming With Unity And C# Will Send You On Your Way To Becoming Comfortable With The Unity Game Engine And Its Documentation And How To Independently Seek Further Information On Yet-untouched Concepts And Challenges. What You'll Learn Understand The Fundamentals Of Object-oriented Computer Programming, Including Topics Specifically Relevant For Games. Leverage Beginner-to-intermediate-level Skills Of The C# Programming Language And Its Syntax. Review All Major Component Types Of The Unity Game Engine: Colliders And Rigidbodies, Lights, Cameras, Scripts, Etc. Use Essential Knowledge Of The Unity Game Engine And Its Features To Balance Gameplay Mechanics For Making Interesting Experiences Who This Book Is For Beginners Who Have No Prior Experience In Programming Or Game Development Who Would Like To Learn With A Solid Foundation That Prepares Them To Further Develop Their Skills. Designed for beginners with no knowledge or experience in game development or programming, this book teaches the essentials of the Unity game engine,the C# programming language, and the art of object-oriented programming. New concepts are not only explained, but thoroughly demonstrated. Starting with an introduction to Unity, you'll learn about scenes, GameObjects, prefabs, components, and how to use the various windows to interact with the engine. You'll then dive into the fundamentals of programming by reviewing syntax rules, formatting, methods, variables, objects and types, classes, and inheritance, all while getting your hands dirty writing and testing code yourself. Later, the book explains how to expose script data in the Inspector and the basics of Unityђ́ةs serialization system. This carefully crafted work guides you through the planning and development of bare bones, simple game projects designed to exercise programming concepts while keeping less relevant interruptions out of the way, allowing you to focus on the implementation of game mechanics first and foremost. Through these example projects, the book teaches input handling, rigidbodies, colliders, cameras, prefab instantiation, scene loading, user interface design and coding, and more. By the end, you'll have built a solid foundation in programming that will pave your way forward in understanding core C# syntax and fundamentals of object-oriented programmingђ́ؤnot just what to type but why it's typed and what it́ђةs really doing. Game Programming with Unity and C# will send you on your way to becoming comfortable with the Unity game engine and its documentation and how to independently seek further information on yet-untouched concepts and challenges. You will: Understand the fundamentals of object-oriented computer programming, including topics specifically relevant for games. Leverage beginner-to-intermediate-level skills of the C# programming language and its syntax. Review all major component types of the Unity game engine: colliders and rigidbodies, lights, cameras, scripts, etc. Use essential knowledge of the Unity game engine and its features to balance gameplay mechanics for making interesting experiences. Designed for beginners with no knowledge or experience in game development or programming, this book teaches the essentials of the Unity game engine, the C# programming language, and the art of object-oriented programming. New concepts are not only explained, but thoroughly demonstrated. Starting with an introduction to Unity, you'll learn about scenes, GameObjects, prefabs, components, and how to use the various windows to interact with the engine. You'll then dive into the fundamentals of programming by reviewing syntax rules, formatting, methods, variables, objects and types, classes, and inheritance, all while getting your hands dirty writing and testing code yourself. Later, the book explains how to expose script data in the Inspector and the basics of Unitys serialization system. This carefully crafted work guides you through the planning and development of bare bones, simple game projects designed to exercise programming concepts while keeping less relevant interruptions out of the way, allowing you to focus on the implementation of game mechanics first and foremost. Through these example projects, the book teaches input handling, rigidbodies, colliders, cameras, prefab instantiation, scene loading, user interface design and coding, and more. By the end, you'll have built a solid foundation in programming that will pave your way forward in understanding core C# syntax and fundamentals of object-oriented programming--not just what to type but why it's typed and what its really doing. Game Programming with Unity and C# will send you on your way to becoming comfortable with the Unity game engine and its documentation and how to independently seek further information on yet-untouched concepts and challenges. You will: Understand the fundamentals of object-oriented computer programming, including topics specifically relevant for games. Leverage beginner-to-intermediate-level skills of the C# programming language and its syntax. Review all major component typ es of the Unity game engine: colliders and rigidbodies, lights, cameras, scripts, etc. Use essential knowledge of the Unity game engine and its features to balance gameplay mechanics for making interesting experiences