Game Programming with Unity and C#: A Complete Beginner's Guide, 2nd Edition Casey Hardman instant download
Game Programming with Unity and C#: A Complete Beginner's Guide, 2nd Edition Casey Hardman instant download
or textbooks at https://ebookmass.com
_____ Follow the link below to get your download now _____
https://ebookmass.com/product/game-programming-with-unity-
and-c-a-complete-beginners-guide-2nd-edition-casey-hardman/
https://ebookmass.com/product/programming-for-game-design-a-hands-on-
guide-with-godot-1st-edition-wang/
Modern C++ for Absolute Beginners: A Friendly Introduction
to the C++ Programming Language and C++11 to C++23
Standards, 2nd Edition Slobodan Dmitrovi■
https://ebookmass.com/product/modern-c-for-absolute-beginners-a-
friendly-introduction-to-the-c-programming-language-
and-c11-to-c23-standards-2nd-edition-slobodan-dmitrovic/
https://ebookmass.com/product/programming-for-game-design-a-hands-on-
guide-with-godot-1st-edition-wallace-wang/
https://ebookmass.com/product/programming-for-game-design-a-hands-on-
guide-with-godot-1st-edition-wallace-wang-2/
https://ebookmass.com/product/c-programming-language-c-programming-
lang-_p2-2nd-edition-ebook-pdf/
Second Edition
Casey Hardman
Game Programming with Unity and C#: A Complete Beginner’s Guide, Second Edition
Casey Hardman
West Palm Beach, FL, USA
■
■About the Author������������������������������������������������������������������������������������������������xvii
■
■About the Technical Reviewer�����������������������������������������������������������������������������xix
■
■Introduction ���������������������������������������������������������������������������������������������������������xxi
■
■Part I: Unity Fundamentals�������������������������������������������������������������������������� 1
■
■Chapter 1: Installation and Setup�������������������������������������������������������������������������� 3
Installing Unity������������������������������������������������������������������������������������������������������������������ 3
Installing Our Code Editor������������������������������������������������������������������������������������������������� 5
Creating a Project������������������������������������������������������������������������������������������������������������� 8
Summary�������������������������������������������������������������������������������������������������������������������������� 9
■
■Chapter 2: Unity Basics����������������������������������������������������������������������������������������� 9
Windows��������������������������������������������������������������������������������������������������������������������������� 9
Project Window�������������������������������������������������������������������������������������������������������������� 10
Scene Window���������������������������������������������������������������������������������������������������������������� 11
Hierarchy Window���������������������������������������������������������������������������������������������������������� 11
Inspector Window����������������������������������������������������������������������������������������������������������� 11
Components������������������������������������������������������������������������������������������������������������������� 12
Adding GameObjects������������������������������������������������������������������������������������������������������ 14
Summary������������������������������������������������������������������������������������������������������������������������ 15
iii
■ Table of Contents
■
■Chapter 3: Manipulating the Scene��������������������������������������������������������������������� 17
Transform Tools�������������������������������������������������������������������������������������������������������������� 17
Positions and Axes��������������������������������������������������������������������������������������������������������� 18
Making a Floor��������������������������������������������������������������������������������������������������������������� 19
Scale and Unit Measurements��������������������������������������������������������������������������������������� 20
Summary������������������������������������������������������������������������������������������������������������������������ 21
■
■Chapter 4: Parents and Their Children����������������������������������������������������������������� 23
Child GameObjects��������������������������������������������������������������������������������������������������������� 23
World vs. Local Coordinates������������������������������������������������������������������������������������������� 25
A Simple Building����������������������������������������������������������������������������������������������������������� 26
Pivot Points�������������������������������������������������������������������������������������������������������������������� 28
Summary������������������������������������������������������������������������������������������������������������������������ 30
■
■Chapter 5: Prefabs����������������������������������������������������������������������������������������������� 31
Making and Placing Prefabs������������������������������������������������������������������������������������������� 31
Editing Prefabs��������������������������������������������������������������������������������������������������������������� 32
Overriding Values����������������������������������������������������������������������������������������������������������� 32
Nested Prefabs��������������������������������������������������������������������������������������������������������������� 35
Prefab Variants��������������������������������������������������������������������������������������������������������������� 36
Summary������������������������������������������������������������������������������������������������������������������������ 36
■
■Part II: Programming Fundamentals��������������������������������������������������������� 39
■
■Chapter 6: Programming Primer������������������������������������������������������������������������� 41
Programming Languages and Syntax���������������������������������������������������������������������������� 41
What Code Does������������������������������������������������������������������������������������������������������������� 42
Strong vs. Weak Typing�������������������������������������������������������������������������������������������������� 42
File-Type Extensions������������������������������������������������������������������������������������������������������ 43
Scripts���������������������������������������������������������������������������������������������������������������������������� 44
Summary������������������������������������������������������������������������������������������������������������������������ 45
iv
■ Table of Contents
■
■Chapter 7: Code Blocks and Methods������������������������������������������������������������������ 47
Statements and Semicolons������������������������������������������������������������������������������������������ 47
Code Blocks�������������������������������������������������������������������������������������������������������������������� 47
Comments���������������������������������������������������������������������������������������������������������������������� 48
Methods������������������������������������������������������������������������������������������������������������������������� 49
Calling Methods�������������������������������������������������������������������������������������������������������������� 51
Basic Data Types������������������������������������������������������������������������������������������������������������ 52
Returning Values with Methods������������������������������������������������������������������������������������� 53
Declaring Methods��������������������������������������������������������������������������������������������������������� 53
Operators������������������������������������������������������������������������������������������������������������������������ 55
Summary������������������������������������������������������������������������������������������������������������������������ 56
■
■Chapter 8: Conditions������������������������������������������������������������������������������������������ 59
The “if” Block����������������������������������������������������������������������������������������������������������������� 59
Overloads����������������������������������������������������������������������������������������������������������������������� 60
Enums���������������������������������������������������������������������������������������������������������������������������� 61
The “else” Block������������������������������������������������������������������������������������������������������������� 62
The “else if” Block���������������������������������������������������������������������������������������������������������� 62
Operators for Conditions������������������������������������������������������������������������������������������������ 63
Equality Operators�������������������������������������������������������������������������������������������������������������������������������� 63
Greater Than and Less Than����������������������������������������������������������������������������������������������������������������� 64
Or���������������������������������������������������������������������������������������������������������������������������������������������������������� 64
And������������������������������������������������������������������������������������������������������������������������������������������������������� 65
Summary������������������������������������������������������������������������������������������������������������������������ 65
■
■Chapter 9: Working with Objects������������������������������������������������������������������������� 67
Classes��������������������������������������������������������������������������������������������������������������������������� 67
Variables����������������������������������������������������������������������������������������������������������������������������������������������� 68
Accessing Class Members�������������������������������������������������������������������������������������������������������������������� 69
Instance Methods��������������������������������������������������������������������������������������������������������������������������������� 71
Declaring Constructors������������������������������������������������������������������������������������������������������������������������� 72
v
■ Table of Contents
Summary������������������������������������������������������������������������������������������������������������������������ 76
■
■Chapter 10: Working with Scripts����������������������������������������������������������������������� 77
Usings and Namespaces������������������������������������������������������������������������������������������������ 78
Script Class�������������������������������������������������������������������������������������������������������������������� 79
Rotating a Transform������������������������������������������������������������������������������������������������������ 80
Frames and Seconds������������������������������������������������������������������������������������������������������ 81
Attributes������������������������������������������������������������������������������������������������������������������������ 82
Summary������������������������������������������������������������������������������������������������������������������������ 84
■
■Chapter 11: Inheritance��������������������������������������������������������������������������������������� 85
Inheritance in Action: RPG Items������������������������������������������������������������������������������������ 85
Declaring Our Classes���������������������������������������������������������������������������������������������������� 86
Constructor Chaining������������������������������������������������������������������������������������������������������ 88
Subtypes and Casting���������������������������������������������������������������������������������������������������� 90
Type Checking���������������������������������������������������������������������������������������������������������������� 92
Virtual Methods�������������������������������������������������������������������������������������������������������������� 93
Number Value Types������������������������������������������������������������������������������������������������������� 94
Summary������������������������������������������������������������������������������������������������������������������������ 95
■
■Chapter 12: Debugging���������������������������������������������������������������������������������������� 97
Setting Up the Debugger������������������������������������������������������������������������������������������������ 97
Breakpoints�������������������������������������������������������������������������������������������������������������������� 98
Using Unity’s Documentation��������������������������������������������������������������������������������������� 100
Summary���������������������������������������������������������������������������������������������������������������������� 101
■
■Part III: Obstacle Course�������������������������������������������������������������������������� 103
■
■Chapter 13: Obstacle Course Design and Outline���������������������������������������������� 105
Gameplay Overview����������������������������������������������������������������������������������������������������� 105
Technical Overview������������������������������������������������������������������������������������������������������ 106
vi
■ Table of Contents
vii
■ Table of Contents
■
■Chapter 17: Walls and Goals������������������������������������������������������������������������������ 147
Walls����������������������������������������������������������������������������������������������������������������������������� 147
Goals���������������������������������������������������������������������������������������������������������������������������� 149
Build Settings for Scenes��������������������������������������������������������������������������������������������� 151
Summary���������������������������������������������������������������������������������������������������������������������� 153
■
■Chapter 18: Patrolling Hazards�������������������������������������������������������������������������� 155
Resembling a Patrol Point�������������������������������������������������������������������������������������������� 155
Arrays��������������������������������������������������������������������������������������������������������������������������� 156
Setting Up Patrol Points����������������������������������������������������������������������������������������������� 157
Detecting Patrol Points������������������������������������������������������������������������������������������������� 160
The “for” Loop������������������������������������������������������������������������������������������������������������������������������������ 161
Summary���������������������������������������������������������������������������������������������������������������������� 178
■
■Chapter 20: Dashing������������������������������������������������������������������������������������������ 179
Dashing Variables��������������������������������������������������������������������������������������������������������� 179
Dashing Method����������������������������������������������������������������������������������������������������������� 180
Final Touches���������������������������������������������������������������������������������������������������������������� 182
Summary���������������������������������������������������������������������������������������������������������������������� 183
viii
■ Table of Contents
■
■Chapter 21: Designing Levels���������������������������������������������������������������������������� 185
Mixing Components������������������������������������������������������������������������������������������������������ 185
Four-Way Shooters����������������������������������������������������������������������������������������������������������������������������� 185
Spinning Blades���������������������������������������������������������������������������������������������������������������������������������� 187
Blade Carousels���������������������������������������������������������������������������������������������������������������������������������� 187
ix
■ Table of Contents
■
■Chapter 25: Obstacle Course Conclusion����������������������������������������������������������� 219
Building the Project������������������������������������������������������������������������������������������������������ 219
Player Settings������������������������������������������������������������������������������������������������������������� 221
Recap��������������������������������������������������������������������������������������������������������������������������� 223
Additional Features������������������������������������������������������������������������������������������������������ 224
Summary���������������������������������������������������������������������������������������������������������������������� 225
■
■Part IV: Tower Defense����������������������������������������������������������������������������� 227
■
■Chapter 26: Tower Defense Design and Outline������������������������������������������������� 229
Gameplay Overview����������������������������������������������������������������������������������������������������� 229
Technical Overview������������������������������������������������������������������������������������������������������ 231
Project Setup���������������������������������������������������������������������������������������������������������������� 232
Summary���������������������������������������������������������������������������������������������������������������������� 232
■
■Chapter 27: Camera Movement������������������������������������������������������������������������� 233
Setting Up��������������������������������������������������������������������������������������������������������������������� 233
Arrow Key Movement��������������������������������������������������������������������������������������������������� 236
Applying Movement������������������������������������������������������������������������������������������������������ 237
Mouse Dragging����������������������������������������������������������������������������������������������������������� 238
Zooming����������������������������������������������������������������������������������������������������������������������� 239
Summary���������������������������������������������������������������������������������������������������������������������� 240
■
■Chapter 28: Enemies and Projectiles����������������������������������������������������������������� 241
Layers and Physics������������������������������������������������������������������������������������������������������� 241
Basic Enemies�������������������������������������������������������������������������������������������������������������� 243
Projectiles�������������������������������������������������������������������������������������������������������������������� 246
Summary���������������������������������������������������������������������������������������������������������������������� 251
■
■Chapter 29: Towers and Targeting��������������������������������������������������������������������� 253
Targeters���������������������������������������������������������������������������������������������������������������������� 253
Tower Inheritance��������������������������������������������������������������������������������������������������������� 259
Tower�������������������������������������������������������������������������������������������������������������������������������������������������� 259
x
■ Table of Contents
TargetingTower����������������������������������������������������������������������������������������������������������������������������������� 259
FiringTower����������������������������������������������������������������������������������������������������������������������������������������� 259
xi
■ Table of Contents
■
■Chapter 34: More Tower Types�������������������������������������������������������������������������� 323
Arcing Projectiles��������������������������������������������������������������������������������������������������������� 323
Cannon Tower��������������������������������������������������������������������������������������������������������������� 329
Hot Plates��������������������������������������������������������������������������������������������������������������������� 332
Barricades�������������������������������������������������������������������������������������������������������������������� 333
Summary���������������������������������������������������������������������������������������������������������������������� 334
■
■Chapter 35: Tower Defense Conclusion������������������������������������������������������������� 335
Inheritance������������������������������������������������������������������������������������������������������������������� 335
UI���������������������������������������������������������������������������������������������������������������������������������� 336
Raycasting�������������������������������������������������������������������������������������������������������������������� 336
Pathfinding������������������������������������������������������������������������������������������������������������������� 337
Additional Features������������������������������������������������������������������������������������������������������ 337
Health Bars����������������������������������������������������������������������������������������������������������������������������������������� 337
Types for Armor and Damage������������������������������������������������������������������������������������������������������������� 338
More Complex Pathing����������������������������������������������������������������������������������������������������������������������� 338
Range Indicators��������������������������������������������������������������������������������������������������������������������������������� 338
Upgrading Towers������������������������������������������������������������������������������������������������������������������������������� 339
Summary���������������������������������������������������������������������������������������������������������������������� 339
■
■Part V: Physics Playground��������������������������������������������������������������������� 341
■
■Chapter 36: Physics Playground Design and Outline���������������������������������������� 343
Feature Outline������������������������������������������������������������������������������������������������������������� 343
Camera����������������������������������������������������������������������������������������������������������������������������������������������� 343
Player Movement�������������������������������������������������������������������������������������������������������������������������������� 343
Pushing and Pulling���������������������������������������������������������������������������������������������������������������������������� 344
Moving Platforms������������������������������������������������������������������������������������������������������������������������������� 344
Joints and Swings������������������������������������������������������������������������������������������������������������������������������ 344
Force Fields and Jump Pads�������������������������������������������������������������������������������������������������������������� 344
xii
■ Table of Contents
■
■Chapter 37: Mouse-Aimed Camera�������������������������������������������������������������������� 347
Player Setup����������������������������������������������������������������������������������������������������������������� 347
How It Works���������������������������������������������������������������������������������������������������������������� 348
Script Setup������������������������������������������������������������������������������������������������������������������ 349
Hotkeys������������������������������������������������������������������������������������������������������������������������ 353
Mouse Input����������������������������������������������������������������������������������������������������������������� 355
First-Person Mode�������������������������������������������������������������������������������������������������������� 357
Third-Person Mode������������������������������������������������������������������������������������������������������� 359
Testing�������������������������������������������������������������������������������������������������������������������������� 361
Summary���������������������������������������������������������������������������������������������������������������������� 362
■
■Chapter 38: Advanced 3D Movement���������������������������������������������������������������� 363
How It Works���������������������������������������������������������������������������������������������������������������� 363
Player Script����������������������������������������������������������������������������������������������������������������� 365
Movement Velocity������������������������������������������������������������������������������������������������������� 369
Applying Movement������������������������������������������������������������������������������������������������������ 372
Losing Velocity������������������������������������������������������������������������������������������������������������� 373
Gravity and Jumping���������������������������������������������������������������������������������������������������� 374
Summary���������������������������������������������������������������������������������������������������������������������� 375
■
■Chapter 39: Wall Jumping��������������������������������������������������������������������������������� 377
Variables����������������������������������������������������������������������������������������������������������������������� 377
Detecting Walls������������������������������������������������������������������������������������������������������������� 379
Performing the Jump��������������������������������������������������������������������������������������������������� 380
Summary���������������������������������������������������������������������������������������������������������������������� 382
■
■Chapter 40: Pulling and Pushing����������������������������������������������������������������������� 383
Script Setup������������������������������������������������������������������������������������������������������������������ 383
FixedUpdate����������������������������������������������������������������������������������������������������������������� 386
Target Detection����������������������������������������������������������������������������������������������������������� 387
xiii
■ Table of Contents
xiv
■ Table of Contents
Summary���������������������������������������������������������������������������������������������������������������������� 421
■
■Index ������������������������������������������������������������������������������������������������������������������ 423
xv
About the Author
Casey Hardman has been a programmer and hobbyist game developer for over eight years. He found
inspiration in the capacity for immersion and interactivity provided by games and has nurtured a passion
for video games since he was a child. In his early teens, this interest led him on a journey into the world of
programming and game design. He works with the Unity game engine, the Godot game engine, and web
development technologies.
xvii
About the Technical Reviewer
xix
Introduction
Welcome to the start of your adventure into game programming with Unity. This book is designed to
teach you how to program video games from the ground up, while still engaging you with plenty of hands-
on experience. It’s not focused on completing ambitious projects, and it’s not about fancy graphics.
We’re learning how to program and how to use the Unity engine. Once you have a solid understanding
of these integral topics, you can expand your knowledge and make more and more complicated and
impressive games.
These may not be the kinds of games you want to work on right away, but I encourage you to follow
along in the order that the chapters are presented. You’ll learn important tips and tricks for coding that will
set you up to advance much more quickly than if you attempted to jump around within the book or tackle
lofty game projects on your own.
Unity is cross-platform, meaning you can run it on a Windows, Mac, or Linux computer. This book
will mostly stick to Windows-based terminology, but you can still follow through with the other operating
systems with little to no extra trouble.
As for system requirements, any modern computer purchased within the last five years or so should
be totally capable of running the software we’ll be working with. Since we aren’t fiddling with high-end
graphics or computing long-winded algorithms, the example projects we develop should run fine on most
systems. However, older systems may run the Unity engine itself slower, which can be frustrating. You can
find the system requirements for the current Long Term Support version (2022.3.6) of the Unity editor here:
docs.unity3d.com/Manual/system-requirements.html
In Chapters 1–5, we’ll begin with a primer for the essential concepts of the Unity game engine itself and
get all our tools set up and ready for action.
In Chapters 6–12, we’ll get into the core details of programming. You’ll start to write your own code and
learn the fundamentals to ensure that you understand not just what code to write, but why you’re writing it
and what it’s actually doing.
In the remainder of the book, we’ll tackle individual projects one at a time, making playable games
that you can polish and add features to later if you please. This is where you’ll get much of your hands-on
experience. We’ll implement actual game mechanics and tackle the hurdles and little hang-ups that come
with a beginner’s approach to the world of game programming.
Game Project 1, “Obstacle Course” (Chapters 13–25), will be a top-down obstacle course where the
player moves their character with WASD or the arrow keys to avoid touching hazards of various forms:
patrolling and wandering hazards, traveling projectiles, and spike traps in the floor. We’ll get practice with
basic movement and rotation, setting up levels, working with fundamental Unity concepts like prefabs and
scripting, and coding basic UI.
Game Project 2, “Tower Defense” (Chapters 26–35), will be the basis of a simple “tower defense” game,
where the player places defensive structures on the playing field. Enemies will navigate from one side of the
field to the other, and the player’s defenses will attempt to fend them off. We’ll explore basic pathfinding
(how the enemies navigate around arbitrary obstacles) and further expand on fundamental programming
concepts.
xxi
■ Introduction
Game Project 3, “Physics Playground” (Chapters 36–44), will be a 3D physics playground with first- and
third-person camera support for a player character with more intricate mouse-aimed movement, jumping,
wall jumping, and gravity systems. We’ll explore the possibilities of Unity’s physics, from detecting objects
with raycasts to setting up joints and Rigidbodies.
xxii
PART I
Unity Fundamentals
CHAPTER 1
Installing software is somewhat simple – download an installer, run the installer, a menu (sometimes called a
“wizard”) pops up, you agree to some terms of use, it asks you where you want to install the program on your
computer, maybe it offers some additional options, and then it starts installing. Easy, right? So I won’t go into
painstaking detail over the installation process. I’ll just show you what to install.
Unity Hub
Unity is frequently releasing new versions with new features, bug fixes, and little improvements. Because of
this, they offer a lightweight little application called Unity Hub that lets you install the actual Unity engine,
including older versions of the engine. It also lets you manage older versions of the engine already installed
on your computer and view all your Unity projects from one place.
Sometimes it’s useful to keep an old version of Unity around even after you upgrade to the latest
version. You may want to work on an older project with the same version you started with, in case some new
features or changes aren’t compatible with your old project – things change, and sometimes the new stuff
breaks the old stuff. Sometimes the old stuff just gets reworked and isn’t valid in a newer version. In those
cases, you might decide to stick to the old version until you finish a project, to avoid spending unnecessary
time changing the way you did something to the “new way.”
So we’re going to install the Unity Hub first, and then we can install the Unity engine itself through the
Hub. To download the Hub, navigate to this link in your web browser:
unity.com/download
This page should show a download button, which may vary based on your operating system. I’m on
Windows, so it shows a button titled “Download for Windows,” as shown in Figure 1-1.
Click this button to download the Unity Hub installer. Once it finishes, run the installer and follow the
prompts.
Once the Hub is installed, run it. You may be prevented from getting very far by Unity asking you to
accept a license, which may involve creating an account with Unity. This is a little one-time setup that pretty
much stays logged in and accounted for afterward. It won’t bother you much once it’s done – but still, if
you’re prompted to make an account, don’t forget your password and username!
Unless you’re working with a big company that’s making money off of products they create with Unity,
then you can just choose the free “Personal” license and be on your way. Unity describes this license as
being for “individuals, hobbyists, and small organizations with less than $100K of revenue or funds raised in
the last 12 months.”
Once you’ve got a license and an account, you should see an “Installs” tab on the left side of the Hub
(see Figure 1-2).
Figure 1-2. Top-left corner of the Unity Hub, with the Installs tab selected
This is where you can see all the versions of the Unity engine you have installed on your computer. You
can also install new versions – although installing many versions can quickly use up space on your hard
drive, so you may want to uninstall old versions to avoid this.
Before we get into that, let’s discuss options for code editors. One can be installed right here through the
Hub with our Unity installation, but there are a few other options that may better suit some users.
4
CHAPTER 1 ■ Installation and Setup
is paused, we can see the state of our code, run it step by step while keeping the game frozen, and resume
whenever we please. This can be very useful in pinpointing why something is going wrong with our code.
Let’s briefly go over the options for code editors:
• Microsoft Visual Studio is a free, feature-packed editor that supports Windows
and Mac. It can be easily installed with debugging support through the Unity Hub.
Unfortunately, it does not support Linux users. It has paid versions for commercial
and professional use, but the free, Community version will be more than enough for
most hobbyist users.
• Microsoft Visual Studio Code, or just Code, is a more lightweight version of Visual
Studio that can operate on Windows, Mac, and Linux. Unfortunately, its latest
versions do not support debugging with Unity, and older versions only supported it
experimentally. It also has a much smaller file size than Visual Studio, which is great
if you’re cramped for space on your computer.
• JetBrains Rider is an editor that supports Windows, Mac, and Linux, as well as
debugging for Unity. Its features are similar to Visual Studio, but unfortunately, it is
not free to use. At the time of writing, it offers a 30-day free trial, after which users
must pay monthly or yearly to continue using the product’s latest version; however,
paying the yearly price once will allow you perpetual access to the version of Rider
that was available at the time, although you will have to pay again if you’d like to use
any newer versions released since your first yearly payment.
Personally, as a Windows user, I use Visual Studio Code for a lot of purposes, as I enjoy its lightweight,
“getting out of the way” design. However, Visual Studio (not Code) can debug Unity out-of-the-box if you
install it through the Hub with your Unity installation, assuming you’re on Windows or Mac. Due to this, I
also have Visual Studio installed for use with Unity and C# specifically.
We’ll be learning how to debug our code using Microsoft Visual Studio later on, in Chapter 12, so if
you’d like to follow along with that chapter, Visual Studio is a fine pick.
Debugging can be a very useful feature, but if you’d like to stay simple for now, or if you’re running
Linux and don’t want to pay for Rider just yet, then you can always pick up Visual Studio Code and learn
about debugging later if you’d like, once you’ve gone through the book and have started branching out on
your own.
To summarize...
• For Windows and Mac users, I recommend using Visual Studio due to its
debugging support and ease of installation through the Hub; however, if your
computer is pinched for space, know that Code will eat up much less space on your
hard drive, so it may prove a better option.
• For Linux users, I recommend Code if you want to stay simple and wait to learn
about debugging later, or Rider if you’d like the full kit of tools and don’t mind that
you’ll have to pay after the free trial.
To download Code, head on over to this link in your favorite web browser:
code.visualstudio.com/download
From there, you can select the correct button to download the software based on your operating system
(Windows, Mac, or Linux). The installer should begin to download. Once it completes, run it and follow the
instructions it provides.
5
CHAPTER 1 ■ Installation and Setup
To download JetBrains Rider, here is the link to the homepage at the time of writing:
jetbrains.com/rider
From the homepage, you should find “Download” buttons sprinkled about in clear view, so give one a
click and follow the instructions.
Installing Unity
Okay, with that settled, let’s install a version of Unity. With the “Installs” tab selected, as shown before in
Figure 1-2, click the “Install Editor” button in the top-right corner. A popup will offer a list of versions you
can choose from.
Unity’s versions are numbered by their year of release, followed by a period and additional version
numbers, such as 2021.2 or 2022.1.
The topmost version will be the latest “LTS” release, which stands for Long Term Support. The LTS
versions are meant for projects that are already in production or are close to release: they won’t have any
changes that will break your project or make you refactor anything, and they are frequently updated to fix
minor bugs or improve performance and stability.
Below the LTS versions, you’ll find “other versions,” which will likely have a more recent version
number. These will have the latest features and changes.
If you’re committing to a project, particularly a large one with a team of developers behind it, Unity
recommends using the LTS version to ensure that the engine doesn’t experience any major changes during
your development cycle. If you’re just experimenting and learning, or just want to see the latest stuff, you
can use the other versions. You can even try beta or alpha versions, although these are likely to be less stable
than the others.
For our purposes, the latest of the “other versions” (below LTS) will do. Click the “Install” button for that
version number. It will be off to the right side of the version number.
You’ll be asked to select what Unity Hub calls “modules” to install with the engine. These are extra little
features to add to the installation, which take up some more space on your computer if you choose to install
them. You can always add modules later, after installation completes, if you find that you want them.
By default, Unity Hub may have already checked a box to install the module called “Microsoft Visual
Studio Community.” If this is the case, you can leave it checked or uncheck it based on the decision you
made earlier regarding which code editor you’d like to go with.
Other notable modules are the Build Support modules, which allow you to build a Unity game project to
different operating systems, environments, and hardware.
“Building” a game project is the process of turning it from a Unity project, playable only through the
Unity engine, to an actual application used to play the game.
Some of the platforms that Unity projects can be built to are
• PC, with support for Windows, Mac, and Linux
• Android
• iOS
• WebGL (played in a web browser)
• Xbox One
• PS5 and PS4
• Nintendo Switch
6
CHAPTER 1 ■ Installation and Setup
Creating a Project
We can now use the Unity Hub to create our first project, so we have an environment to play around in as we
learn. In the Unity Hub, click the Projects tab on the left side, and then click the blue “New project” button in
the top-right corner.
A dialog box will appear, allowing you to select a template to base the project on.
The template is just a simple starting point for your project. The most bare-bones and simple templates
are the first two, titled “2D” and “3D.” These are pretty much blank slates, one set up for 2D games, and
one for 3D.
We’ll start with a blank 3D project, so select the 3D template by clicking it. It will have a blue border
around it if it is selected, as shown in Figure 1-3.
On the right side, there’s a description of the template. Beneath that description, there’s a “Project
Settings” header where you can supply a name for your project, as well as select where you want to store it
on your computer.
7
CHAPTER 1 ■ Installation and Setup
We’ll name our project “ExampleProject” – note that we aren’t using a space between the two words,
because file paths aren’t always fond of spaces.
You can change the directory to save the project wherever you like. Whatever file path you choose, a
folder named after the project will be created there. That folder is the “root directory” for your project, and
all your project’s files and resources will be stored in that folder.
Once you’ve selected the path you want, click the “Create project” button in the bottom-right corner,
and wait for Unity to create the base project files. This may take a few minutes. When Unity finishes, the
editor itself will pop up with your brand-new project opened and ready for editing.
Summary
The following is a recap on what we learned in this chapter:
• The Unity Hub program will be used to download new versions of the Unity editor,
uninstall old versions you no longer need, create new projects, and open existing
projects.
• Opening a project in the Unity Hub will start the Unity editor, which is where we’ll
actually use the engine to develop our game.
• A Unity game project is stored on your computer, with all the related files – including
stuff we make ourselves like art and code – stored in a “root directory” named after
the project name.
• Our code will be written with a text editor designed specifically for writing code.
This offers us useful features that normal text editors don’t have, making it easier to
format and navigate our code.
8
CHAPTER 2
Unity Basics
Now that we have Unity set up and a new project to work with, let’s get comfortable with the engine. This isv
the user interface we will be interacting with quite a lot as we develop our games, after all, so we ought to get
to know it early.
Windows
Unity is separated into different windows that serve different purposes. Each window has a little tab at its
top-left corner where the type of the window is written.
Each of these windows is a separate piece of the program that can be positioned and sized how we want
it, or even altogether removed. There are a handful of other window types in Unity that aren’t being used
now, so we don’t see them on our screen – but if we ever wanted to use them, we could add them with a
few clicks.
You’ll notice that if you left-click and drag one of these window tabs, the window can be picked up and
moved to a different spot in the program. Doing this, you can split one window’s space to cover some of it
with a different window. If you ever want to rearrange your windows in a certain way, chances are you just
need to start dragging stuff around and see how Unity reacts.
You can also dock windows beside others to place their tabs side by side (see Figure 2-1). Whichever tab
you clicked last will gain focus and fill the space of the window.
Figure 2-1. Two window tabs docked side by side in the same space. The Project window has focus and will
fill the space, but the Console window can be given focus instead by clicking its tab
Unity also lets you save all your current windows and their sizes and positions in a layout, which you
can assign a name to. This is done with the little drop-down button in the top-right corner of the Unity
editor, with the text “Layout” written on it. Click this button to see all of the built-in layouts you can choose
from, as shown in Figure 2-2.
Figure 2-2. The Layout button in the top-right corner of the Unity editor, after it has been clicked to show
its options
By default, it will be set to a layout very aptly named “Default.” Try clicking a different layout, and you’ll
see Unity automatically restructure all its windows for you. You can also select the “Save Layout…” option
in the drop-down list to save your current layout under a new name to keep it around, once you’ve set
things up the way you like. That way, if you ever unintentionally close a window or accidentally cause some
catastrophe to your window setup, you can just reset it to the way you had it by loading your layout with the
drop-down.
Layouts can also be useful when dealing with different aspects of game development. Certain activities
might be easier to do with a different set of windows in different positions. The ability to save layouts makes
it easier for us to hop back and forth between activities – we can do it with just a few clicks.
The default layout has all the most important windows, so you don’t have to change anything if you
don’t want to. Let’s go over these windows to learn about what they do.
Project Window
The Project window can be found in the bottom-middle section of the editor by default, paired alongside
a window called Console – which we’ll learn about later, as it relates directly to code. The Project window
shows us all of our assets. An asset is the game development term for some piece of work we can use in our
game – art, sound effects, music, code files, game levels, things like that.
Once we get around to making assets, we’ll see them here in the Project window. It pretty much
functions like your computer’s file system. You store assets in folders, also known as directories. You might
have a folder for all your sound effects, another for all your code files (called “scripts”), and so on. We
organize it all however we like in this window, and it’s from this window that we can find, select, and use our
assets within the engine.
Our project has been set up with some folders for us by default: the Packages folder – which we don’t
need to pay any attention to right now – and the Assets folder, which is the root folder inside which all our
assets will be stored. The arrow beside a folder can be clicked to hide or show its contents (if it has anything
inside it). If you unfold the Assets folder, you’ll see it already has a “Scenes” folder inside it and an asset
named “SampleScene”.
10
CHAPTER 2 ■ Unity Basics
Scene Window
The Scene window can be found dominating most of the screen space, docked in the upper left with the
Game window. It lets you see the environment your game is taking place in. What we might call a “level” in
our game is a “scene” in Unity. Scenes are saved as assets, so we’ll see them in our Project window when we
save them – this scene is the “SampleScene” asset we have in our project by default.
Each scene has its own collection of objects in it. The Scene window lets you view a scene and navigate
through it, like a floating camera observing your game world. It’s your main viewport into the game
environment.
The sample scene we have open now doesn’t really have anything inside it yet – just a light, which is an
invisible object that casts light over everything in the scene, and a camera, which is the object through which
the player will see the scene when the game is being played. It should also have a basic sky and horizon
showing.
If we had other scenes, which we will later, we would store them all in our Scenes folder, and double-
clicking one of them there would load a different scene, letting us view and edit that scene instead.
Within the Scene window, moving your mouse while holding right-click will turn the camera, much like
looking around in a first-person game. While holding right-click, you can use the WASD keys to move the
camera around – once again, much like in a game: W to move forward, S to move backward, A to move left,
and D to move right. You can also use Q to move directly down and E to move directly up. Holding down the
middle mouse button while dragging will pull your camera without turning it.
Hierarchy Window
The Hierarchy window, in the bottom left by default, allows you to see the objects contained within the
current scene. As we just covered, a scene is pretty much just a collection of objects. When we switch from
one scene to the other, we’re just tucking away all the objects in the current scene and pulling out all the
objects in the new scene instead.
You can see that those two objects we mentioned in our scene are listed in the Hierarchy: a “Directional
Light” and a “Main Camera.” By default, we’ll have a light source and a camera in our scene, so we’ll see
them both listed here in the Hierarchy (this camera isn’t the one we’re viewing the scene through in the
Scene window – rather, it’s the camera that the player will be viewing the game through).
These are GameObjects. Simply put, a GameObject is some object in your scene. It could be a prop,
like a box or a plant or a tree. It could be the player character, an enemy, a power-up on the ground, or a
disembodied light. It could even be a GameObject that does nothing: it just exists, invisible in the scene. At
their simplest, they’re just a point in space with a name.
Inspector Window
The Inspector window, covering the right side of the editor by default, is a very important window that we
will use extensively in our adventures with Unity.
As we just went over, the Hierarchy window shows a list of all GameObjects in the scene. Click one of
these GameObjects in the Hierarchy window to select it. You will notice that this causes the Inspector to
change. It’s now showing you information about the selected GameObject. At the top of the Inspector, you
can see a box containing the GameObject name, which you can click to type a new name in if you please.
There are also a few drop-down buttons, one for the “tag” and one for the “layer” – we’ll learn what those are
for later.
But the main functionality of the Inspector is to show us all the components attached to the selected
GameObject(s).
11
CHAPTER 2 ■ Unity Basics
Components
A component is a Unity term for a feature, some single piece of game functionality, that is attached to a
GameObject. A component cannot exist without a GameObject to attach it to.
There are many different kinds of components that serve different purposes, all included in the Unity
engine by default. There’s the Light component to cast light, whether it’s a sunlike light that covers the whole
scene or something like the beam of a flashlight.
Let’s look at a Light component. Since the Inspector is designed to show us the components of the
selected GameObject, try clicking the Directional Light in the Hierarchy window to select it. You’ll see the
Inspector update after you do this, to look something like Figure 2-3.
Figure 2-3. A view of the Inspector with the default Directional Light GameObject selected
12
CHAPTER 2 ■ Unity Basics
Beneath the basic information at the top, like the GameObject’s name, you’ll see a heading for each
component attached to the GameObject. This GameObject has two components attached: Transform and
Light. You can click the headings of these components (where the component name is) to hide them (also
known as “folding” them) or show them. Beneath the header, the various properties of the component are
listed as value fields that we can change to affect the component – make the light more intense, change its
color, change the way it casts shadows, and so on. The field name is on the left side, and the field value is on
the right side. Some of these field values are numbers, and some are little “sliders” that let you click and drag
a dial with your mouse – you’ll come across many kinds of fields designed to edit different sorts of values.
This is the major functionality of the Inspector: viewing and editing the properties of components on a
GameObject.
Another example is the Camera component. It’s essential. It’s what renders (“render” means “draw
to the screen”) the scene to the player’s screen when the game is playing. If you select the Main Camera
GameObject in the Hierarchy window, you’ll see the Camera component listed in the Inspector.
When we start making things ourselves later in the book, we’ll be getting some hands-on experience
with using many kinds of components. Unity also has helpful official documentation, and this can be easily
accessed by clicking the little icon that looks like a “?” symbol, located on the right side of each component
header in the Inspector. This will open the documentation for that specific component type in your default
web browser.
Our code will be attached to GameObjects in the form of components as well. They’re called “scripts”
in this case: that is to say, a script is a component which runs our code when it’s attached to a GameObject.
So when we write code, the way we get it into the game is by attaching it as a script component to a
GameObject.
This means we can reuse and mix different pieces of functionality, if we’re smart about how we write
and define our scripts.
For example, our first example project is a game where the player must avoid various obstacles. Let’s
say you’re making a project like this, and you want to make different kinds of obstacles to keep the game
interesting. You want obstacles that shoot fireballs, blades that spin in a circle, and rolling spike balls that
move back and forth between two points.
Each of these pieces of functionality can be made into a separate script component: Shooting, which
periodically fires projectiles in front of the GameObject; Spinning, which makes the object constantly twirl
around; and Patrolling, which makes the object pace back and forth between two or more points. Then, we
can have a component called Hazard that we attach to the fireballs, the spinning blades, and the patrolling
spike balls, which makes them kill the player when they touch.
The cool thing about components is that we can then mix them with each other to create new types of
obstacles.
Because each different piece of functionality is contained within its own component, we can
make anything shoot, spin, patrol, or kill the player on touch. And since we aren’t limited in how many
components we can add to a single GameObject, we can make a fireball-shooter that spins in a circle by
attaching both the Shooting and Spinning components to a single GameObject. We can attach a blade to its
opposite side which acts as a hazard. We can make a patrolling spike ball that shoots fireballs in front of it.
You get the point. As long as each piece of functionality is part of its own script component, we can
simply throw any combination of script components onto one GameObject to fuse all the different things we
coded onto that object.
This is one of the major advantages of Unity’s component system. It provides a system where we can
mix different features however we please.
13
CHAPTER 2 ■ Unity Basics
Adding GameObjects
Let’s start getting familiar with using Unity to create and manipulate some GameObjects. We won’t be
making character models, spaceships, guns, or anything fancy like that from within the Unity engine. Unity
is not a modeling package (to create 3D objects) or an image editor (to create 2D objects). It’s a game engine;
you make the models and animate them in other software, and then you import them into Unity by simply
putting them into your project folder, where Unity makes sense of them and lets you drag and drop them
into your scenes.
For the sake of learning the engine and learning to program, we won’t be messing around with fancy art.
However, Unity can create GameObjects of basic shapes for us on the fly with just a few button presses.
Just beneath the top of the Unity editor (the title bar), you’ll see a bar with a selection of different
buttons: File, Edit, Assets, GameObject, Component, Services, Window, and Help. These can be clicked to
drop down a menu with further options.
The GameObject drop-down menu can be used to create simple, frequently used GameObjects: basic
3D shapes, cameras, lights, and so on.
Using this menu, we can create a cube through GameObject ➤ 3D Object ➤ Cube, as shown in
Figure 2-4. Alternatively, you can also right-click anywhere in the Hierarchy, but not on the name of an
existing GameObject, and use the context menu to select 3D Object ➤ Cube.
14
CHAPTER 2 ■ Unity Basics
After doing either of these things, you’ll notice a Cube will be added to our Hierarchy and will show up
in the scene if your camera is pointing at it.
If you can’t see it in the scene, your view is probably out of whack. You can easily navigate your view to
a GameObject in the current scene by clicking the object in the Hierarchy window to select it, then putting
your mouse over the Scene window so it has focus, and then pressing the F key. This is a handy shortcut that
moves your view over to the selected objects so you can see them. If you ever move so far away from your
objects in the Scene window that you get lost, just use this.
To expand on our talk about components earlier, let’s check what components are present in this cube
we just made. Making sure the cube is selected, look at your Inspector window.
The topmost component will always be a Transform. Every GameObject has a Transform component.
A Transform is a position, size, and rotation. It’s essential to a GameObject. You can remove components on
the fly with code, but you can’t remove a Transform. You have to delete the whole GameObject if you want to
destroy its Transform component. Every object that exists in your scene must have a position, right? It has to
be somewhere.
Aside from the Transform, you’ll notice a few other components. There’s a Mesh Filter and a Mesh
Renderer.
The word mesh is pretty much synonymous with “3D model” as far as we’re concerned. It’s an asset that
defines the surfaces that make up a 3D model. Again, we won’t be making our own meshes – we’ll be using
the default shapes provided by Unity, like cubes, capsules, spheres, and cylinders. Render is just a fancier-
sounding word for drawing or displaying something on the screen.
So a Mesh Renderer is a component that allows a 3D model to be drawn, although the drawing of it is
done by a Camera component.
The Mesh Filter is a component that holds the mesh you want to pass to the Mesh Renderer. Pretty
much whenever you see a Mesh Renderer, you’ll see a Mesh Filter as well, because the Filter tells the
Renderer what to render.
You’ll notice a little check mark beside the Mesh Renderer component in the Inspector. Components
like this can be enabled and disabled by clicking this check mark. Just in case you don’t believe that the
Renderer component is actually drawing the cube to the scene, try clicking that check mark to uncheck it.
You’ll notice that the cube stops rendering to the screen in the Scene window. Check it again, and it’ll pop
back up.
Summary
In this chapter, we learned the following:
• The Unity editor is made up of various windows that serve unique purposes. Any
window can be rearranged and resized by clicking and dragging the tab at its left-
top corner.
• An asset is a file for use in our game, such as art, audio, or code. These are viewed
in the Project window, and often we’ll incorporate them into our game by simply
dragging and dropping from that window.
• A scene is an asset that resembles a game environment, like an individual level. We
can double-click them in the Project window to load them, allowing us to view and
edit them in the Scene window.
• A GameObject is an object that exists in the scene. Their functionality is driven by
components that we attach to them. Unity provides many built-in components for
fundamental things like displaying a 3D model, casting light, providing physics and
collisions, and so on.
15
CHAPTER 2 ■ Unity Basics
16
CHAPTER 3
We’ve learned the basics of the most important windows in the Unity engine, and we know how to create
simple objects and view their components through the Inspector. Now let’s get familiar with moving,
rotating, and sizing GameObjects in our scene.
Transform Tools
We learned in the last chapter that a Transform is the component type that all GameObjects have, which
provides them with a position in the world, a scale (size), and a rotation. The Transform tools in our Scene
window allow us to interact with the Transforms of selected GameObjects.
The Transform tools are docked at the top-left corner of the Scene window by default, although you can
drag the two lines at their top to move them around within the Scene window. Doing this, you can also drag
and drop them under the Scene tab to lock them in place with the other buttons at the top of the window, as
shown in Figure 3-1.
Figure 3-1. The Transform tools popped out into the Scene window (top) and locked in under the window tab
(bottom)
There are six buttons for six different kinds of Transform tools, and depending upon what GameObject
you have selected, you may also see a seventh button for custom editor tools – but we don’t need to concern
ourselves with that right now. If you don’t see a seventh button, don’t worry about it.
Each of these buttons can be clicked to switch to a different tool. Only one tool is ever active at a time,
and they all serve different purposes.
From top to bottom (or left to right), you can use the hotkeys Q, W, E, R, T, and Y to toggle between
these tools.
The first tool, with the hotkey Q, is the hand tool, which lets you left-click and drag on the screen in the
Scene view to drag your scene camera around. It doesn’t edit the scene. It just helps you navigate it. Clicking
and holding the middle mouse button while dragging will automatically employ the hand tool, if you’d
rather use it that way.
The other tools will allow you to edit the GameObjects you are selecting. In the Scene window, the
transform tool you have selected will provide little “gizmos” on or around your selected GameObjects. These
gizmos are simple tools that we click and drag to use the Transform tool to interact with the GameObject.
You will notice, if you select a GameObject and toggle between these tools, that the gizmo drawn around the
object changes as the selected tool changes.
W is the position tool. While active, it shows arrow gizmos on your selected GameObject. You can drag
the object in specific directions by clicking and dragging the arrows. You can also drag it along two directions
at once by clicking the square shapes between arrows.
E is the rotation tool. It shows circle gizmos on the selected GameObject. Clicking and dragging the
circles will spin the object, and each circle turns it along different directions. You can also click in the middle
of the gizmo, between the circles, to turn the object in multiple directions at once. Clicking the outer, gray
circle will spin the object relative to your camera.
R is the scale tool. It shows gizmos like the arrows, but with cube-shaped ends. Click and drag these
boxy arrows to change an object’s width (red), length (blue), or height (green). Click the cube in the center
of the gizmo and drag to scale the entire object at once – that is, raising or lowering the width, height, and
length evenly at once.
T is the rect tool (“rect” being short for “rectangle”). It is most applicable to 2D projects, but can have its
uses in 3D as well. The gizmo shows a rectangle around the selected object, with circles at the corners. The
edges or corners can be clicked and dragged to expand or shrink the object as a rectangle, affecting both the
position and scale at once. This can be useful to make an object larger or smaller on one side only, since the
scale tool will affect the scale on both sides.
There’s also a circle at the center of the gizmo which can be clicked and dragged to reposition the object
along the two directions that the rectangle is aligned with. You’ll notice that the rectangle gizmo operates on
two directions at any time. Attempting to move your camera over to the side of the rectangle will cause it to
flip around and face the camera again.
The Y tool combines the W, E, and R tools, showing the arrows for moving, the circles for rotating, and
the cube at the center for scaling, all at once.
18
CHAPTER 3 ■ Manipulating the Scene
Making a Floor
Let’s use what we’ve learned to make some cubes, position them, and scale them. But first, let’s make a floor.
Create a Plane, using the same method we made the cube in the last chapter: GameObject ➤ 3D Object
➤ Plane.
A plane is like one surface of a cube – a paper-thin, flat surface that has no thickness. They’re one-
sided: you can’t see them at all if you look at them from the backside. Try navigating your camera beneath
the plane and looking up at it. You won’t see anything, as if it never existed. Still, it’ll serve fine for our floor,
because we don’t expect to be looking at it from below.
Because we know exactly where we want our floor to be, we can set it up using the Inspector. With the
new Plane selected, look to its Transform component in the Inspector.
As stated before, the Transform has a position (where it is), rotation (how it’s turned about), and scale
(how large it is).
Remember, the Inspector’s primary purpose is to interact with components, not just to view their
data: it exposes the actual values of the position, rotation, and scale of the Transform to us. We can edit the
individual axes to our liking, simply by clicking these fields and typing in the numbers we want.
This is a useful way to set things up if you know exactly how you want to set them up, because getting
precise values for positions and rotations using the Transform tools can be very tedious. We want our plane
to be at the world origin (the center of the scene), so use the Inspector to change its position to 0 on all three
axes, if it isn’t already. As for the rotation, it should be (0, 0, 0) already, so leave it as is.
19
CHAPTER 3 ■ Manipulating the Scene
Figure 3-2. A Plane and a Cube, both with scale (1, 1, 1) and positioned in the exact same spot
This is because the size of their actual meshes is not the same. Even if their scale is the same, the cube
mesh is 1 unit wide and long, while the plane is 10 units wide and long. Since their scale is just a multiplier
of the mesh size, not a depiction of the actual size of the object, the scale of (1, 1, 1) is not affecting the mesh
size at all. It’s multiplying by 1, so of course, it’s leaving them as is.
Now, if we change that cube to have a scale value of (10, 1, 1), it will become 10 units wide, which
matches the plane exactly, as shown in Figure 3-3.
20
CHAPTER 3 ■ Manipulating the Scene
Figure 3-3. A Plane with scale (1, 1, 1) at the same position as a cube with scale (10, 1, 1). The cube is exactly
as wide as the plane
To sum it up, just remember this: the mesh has its own size, and the scale is merely a multiplier for the
mesh size. It is not a flat value depicting “how big the mesh is.”
All that aside, let’s press on and finish setting up our floor. We want a large floor so we don’t have to
worry about making it bigger every time we want to put some more stuff on it. Let’s set its scale to 10 on the
X and Z axes – which, mind you, is actually 100 units wide and 100 units long. Of course, it’ll be easier to just
set the X and Z scale values to 10 in the Inspector rather than using the scaling tool.
Summary
In this chapter, we learned the following:
• How to manipulate the position, rotation, and scale of GameObjects using the
transform tools (hotkeys W, E, and R).
• Positions are resembled as an X, Y, and Z value. Adding to a value moves in one
direction, while subtracting from it moves in the opposite direction. X is right
(positive) and left (negative), Y is up (positive) and down (negative), and Z is forward
(positive) and back (negative). By combining all three values, we can define a 3D
point in space.
• Scale is a multiplier for the size of the actual mesh that the GameObject is rendering.
It’s not the number of units wide, tall, and long a GameObject is. Rather, the X, Y, and
Z scale of the Transform multiplies the size of the mesh that’s being rendered.
• A single unit doesn’t correspond to a particular number of feet or inches or meters
by default in Unity. We have to decide what a unit means ourselves, and as long
as we stay consistent with that decision, our objects will end up properly sized in
proportion to each other.
21
CHAPTER 4
Now that we have our floor set up, let’s dive into some very important concepts employed by game engines.
Unity allows us to attach individual GameObjects to each other in a system known as “parenting,” where
“children” are attached to a “parent” GameObject and thus move, rotate, and scale with it. This creates a
distinction between two ways of looking at an object’s position: its world position, which resembles where it
is in the scene, and its local position, which resembles where it is in relation to its parent. This also gives us
an option to define parents and children in a way that lets us set up pivot points to change the point around
which objects rotate.
Child GameObjects
There’s a reason why the Hierarchy window is called a hierarchy. We haven’t exhibited that reason yet, but
we’re about to.
A GameObject is capable of storing any number of other GameObjects “inside it.” This system is called
parenting: one GameObject may be the parent of many others, and those GameObjects stored inside it
would be called its children.
Technically, Unity looks at this as the Transform components being attached to each other, because
that’s where the actual relevance of the concept is seen. Making one GameObject the child of another is like
physically attaching it to its parent. Because the Transform deals with the physical position, rotation, and
size of an object, this essentially means attaching the Transforms to each other.
When the parent Transform moves, its children move with it. When the parent rotates, the children
pivot as if they were attached to the parent, even if there are miles of open air between them. When the
parent becomes smaller or larger, the children follow suit proportionately.
Let’s play with this concept so you can see it in action.
Create two cubes and position them anywhere apart from each other. It doesn’t really matter where,
as long as they aren’t directly on top of each other – they can touch or overlap if you want. Use the position
transform tool (hotkey W) to do this.
Now, scale one cube up a little. You can do so in the Inspector by setting its scale to something like 1.5
on all axes, or simply puff it up a little with the scale transform tool (hotkey R). When you’re done, it should
look something like Figure 4-1.
Figure 4-1. A cube with (1.5, 1.5, 1.5) scale (left) and a second, unchanged cube positioned off to its
side (right)
That larger cube will be our parent. Select it to see which cube it is in the Hierarchy (it will be
highlighted, since it is selected). Using the Inspector, change its name to “Parent” so it’s easy to recognize.
Now, click the other cube in the Hierarchy to select it. Then, click and drag this cube in the Hierarchy,
and drop it over the “Parent” cube.
Once you’ve dropped it, the Hierarchy begins to look like a hierarchy for the first time. The dragged
cube is now a child of the “Parent” cube and is now “inside” its parent in the Hierarchy. This is shown by its
indention: the children will be offset to the right a little further than their parent GameObject. In Figure 4-2,
you can see our Parent cube, a Cube child inside it, and another GameObject beneath which is not a child.
Notice that the “Cube” child is pushed to the right side a little bit, denoting that it is a child of “Parent.”
Figure 4-2. View of our two cubes in the Hierarchy window. The “Cube” GameObject is a child of the “Parent”
GameObject. The third GameObject is not a child, as seen by its indention
You’ll also notice that the parent now has a little arrow icon on its left side, which can be clicked to hide
or show its child GameObjects in the Hierarchy. This can be useful to tuck away a complicated hierarchy of
GameObjects that’s cluttering your view.
Now that the cube is a child of the parent, any Transform changes we make to the parent will affect
the child cube. The opposite is not true – the child can be moved, rotated, or scaled without any changes
applying to the parent, but any movement, rotation, or scaling you apply to the parent will always affect the
child as well.
Try it yourself. Select the Parent cube, go to the Scene view, and use the Transform tools (W, E, and R)
to move, rotate, and scale the cube. If your transform tool gizmos are showing between both cubes, this is
because the Tool Handle Position setting is set to “Center.” Press Z to set it to Pivot instead, which should
make the gizmos be centered on the Parent cube.
When moving and rotating the parent, the child will move with it and pivot around it, as if some
invisible bar is attaching them to each other. When scaling the parent, the child will scale as well – they
will both grow larger or smaller, and the distance between them is kept the same proportionately to their
new size.
24
CHAPTER 4 ■ Parents and Their Children
25
CHAPTER 4 ■ Parents and Their Children
A Simple Building
Let’s use cubes to assemble a shape similar to a building – picture a blocky skyscraper, with no detail on the
outside whatsoever, just flat surfaces. We’ll learn a little about how to position objects when creating them,
and we’ll practice the concepts of parenting while we’re at it.
Our building is going to be made of three cubes. The bottom one will be the base – thicker and shorter.
The middle and top will each be thinner and taller than the last. We’ll center the cubes so they all have the
same X and Z positions (forward/back and right/left) but raise and lower them so that they make a sort of
tower, almost like a stack of blocks. In the end, it will look something like Figure 4-3.
First, before you embark upon this quest, make sure you’re not lost in some awkward orientation
within the Scene view. You can use the little gizmo in the top-right corner to see how your camera is rotated,
almost like a compass (shown in Figure 4-4). The arrows are color-coded by axis, as we mentioned before. If
you’ll recall
• The X axis is red, and it corresponds to right and left. Increase the X to go right.
Decrease the X to go left.
• The Y axis is green, and it corresponds to up and down. Increase the Y to go up.
Decrease the Y to go down.
• The Z axis is blue, and it corresponds to forward and back. Increase the Z to go
forward. Decrease the Z to go back.
26
CHAPTER 4 ■ Parents and Their Children
Figure 4-4. Gizmo in the top-right corner of the Scene window. The axis that the arrow corresponds to is
written beside it, and each arrow is color-coded by axis
The colored arrows, with the axis letter written beside them, all point along the positive direction of
their axis. The gray arrows point in the opposite direction, which is the negative direction of the axis. In other
words, the colored arrows point to the actual world direction of right, up, and forward. So the green arrow,
corresponding to the Y axis, is always pointing up. This means if that arrow is pointing down for you, then your
camera is upside down. The gizmo is telling you where “up” really is. If it’s not already, realign your camera by
holding right-click while moving the mouse until you have the green Y arrow pointing up, as it is in Figure 4-4.
Now create a cube. Make sure it’s selected and change its name to Cube Base at the top of the Inspector.
We’ll make it thick, but short. Using the Inspector, set its Transform scale to something like (10, 4, 10). That’s
10 on the X and Z axes, but only 4 on the Y axis (height).
There are several ways to ensure that one object is aligned with another when you create it. Every object
you create is placed at some certain spot in front of the camera. If you create another cube without ever
moving your camera since you made the first one, they’ll both be in the same spot.
If you ever use the shortcut that we described earlier to center your camera on a selected object, which
is done by pressing F, you’ve also positioned your camera such that any new object created will have the
same position as the object you’ve focused on. It puts the camera in a place where the objects you create will
go exactly on top of that focused object.
So if you’ve moved the camera since creating your Cube Base, you can simply make sure it’s selected
and then press F while your mouse is over the Scene window. This will put focus on the Cube Base, moving
the camera to look at it. Any new objects you create will be placed in the same position of the Cube Base, so
create another cube now, and it should be in the same spot. You can also simply copy-paste the values from
the Cube Base position to that of the new cube using the Inspector.
But all of these objects are meant to be attached to each other, so we know we’re going to use parenting
anyway. It makes sense that the upper cubes would be attached to the lower cubes, right? So when you
create your new cube, name it Cube Middle and make it a child of the Cube Base. This makes it even easier
to see if they’re aligned correctly, since the Inspector will now be showing us the local position of Cube
Middle. If they’re in the same spot, Cube Middle will have a position of (0, 0, 0).
We want to make sure it’s centered on the X and Z, so if the X and Z position values of Cube Middle are
not 0 already, set them to 0. Now you can simply use the position and scale Transform tools (W for position
and R for scale) to move the Cube Middle up above the Cube Base and scale it up until it’s a good size, if you
want to go by eye.
Do the same thing for a third cube, named Cube Top. If you want, you can copy-paste Cube Middle
(Ctrl+C, Ctrl+V) and then rename it, so that it starts right at the same position, or start fresh with a new cube
and set its local position to (0, 0, 0) to center it again. Make it a child of Cube Middle, not Cube Base, because
the Cube Top is technically attached to the middle cube – that is to say, if we wanted to just rotate or move
the middle cube, we would expect the top cube to rotate or move with it.
27
Other documents randomly have
different content
really free scope, and if at the same time there exists the will and possibility
to do what is necessary to their satisfaction. These interests arise in a region
outside the confines of the economic life. They grow up as man’s own being
unfolds its soul and physical nature. It is the business of economic life to
make arrangements for their satisfaction. The only arrangement however
that the economic life can make, are such as are limited to the delivery and
exchange of commodities,—that is of goods which acquire their value from
men’s wants. The value of a commodity comes from the person consuming
it. And owing to the fact, that its value comes from the consumer, a
commodity occupies quite a different position within the social organism
from other things that have a value for man as part of that organism. Study
the whole circle of economic life, putting aside all preconceptions,—the
production, circulation and consumption of commodities going on within it.
One observes at once the difference in character between the relation that
arises when one man makes commodities for another, and that human
relation that has its foundation in mutual right. One will not however stop
short at merely observing the difference; one will follow it up practically,
and insist that economic life and the life of “right” should be kept
completely separate within the body social. Institutions devoted to the
production and exchange of commodities require men to develope forms of
activity that are not immediately productive of the very best impulses for
their mutual relations in “right.” Within the economic sphere man turns to
his fellow because it suits their reciprocal interests. Radically different is
the link between man and man in the sphere of “right.”
It may be thought perhaps, that the distinction which life requires between
the two things is adequately recognised, if the institutions established for
the purposes of economic life also make provision for the “rights” that are
involved in the mutual relations of the people engaged in it. But such a
notion has no root in reality. The relation “in right,” that necessarily exists
between a man and his fellows, is one that can only be rightly felt and lived
outside the economic sphere, on totally different soil, not inside it. In the
healthy social organism, therefore, there must be another system of life,
alongside the economic life and independent of it, where human rights can
grow up and find suitable administration. But the “rights” life is, strictly, the
political sphere,—the true sphere of the State. If the interests that men have
to serve in their economic life are carried over into the legislation and
administration of the “rights” State, then these rights as they grow up will
merely be an expression of economic interests; whilst, if the “rights” State
takes on the management of economic affairs, it is no longer fitted to rule
men’s “life of rights”; since all its measures and institutions will be forced
to serve man’s need for commodities, and thereby diverted from those
impulses which make for the life of rights.
A typical example of the fusion of the economic life with the rights-life was
afforded by Austria. According to the constitution adopted by Austria in the
eighteen-sixties, the representatives of the imperial assembly, the
“Reichsrat,” of that compound territory, were elected from the communities
representing the four branches of economic life:—the landed proprietors,—
the chambers of commerce,—the towns, markets and industrial centres,—
and the rural areas. Obviously, in this composition of the representative
State-assembly, the first and only idea was, that of playing off the economic
interests against one another, in the belief that a system of political rights
must be the outcome. No doubt the disruptive forces of her divers
nationalities contributed largely to Austria’s downfall. But it may be taken
as no less certain, that if an opportunity had been given for developing a
system of “rights,” working alongside and outside of the economic one, it
would, from the common sense of right, have evolved a form of society in
which the different nationalities could have lived together in unity.
A person engaged in public life to-day usually turns his attention to things
in it that are only of secondary consideration. This is because his habits of
thought lead him to regard the body social as uniform in structure. As a
uniform structure, there is no form of suffrage he can devise that will fit it;
for the economic interest and the impulses of human rights will come into
mutual conflict upon the representative body, however it may be elected;
and the conflict between them will affect social life in a way that must
result in severe shocks to the whole organism of society. The first and
indispensable object to be worked for in public life to-day must be the
radical separation of economic life from the “rights” organisation. And as
the separation becomes gradually established, and people grow into it, the
two organisations will each in the process discover its own most appropriate
method of selecting its legislators and administrature. Amongst all that at
the present moment is clamouring for settlement, forms of suffrage,
although they bear on fundamental issues, are nevertheless of secondary
consideration.
Where the old conditions still exist, these can be taken as the basis from
which to work towards the new separation of function. Where the old order
has already melted away, or is in process of dissolution, there individuals
and little groups of people must find the initiative to start reconstructing
along the new lines of growth. To try in 24 hours to effect a transformation
in public life, is recognised by thoughtful socialists themselves as
midsummer madness. They look to gradual opportune changes to bring
about what they regard as social welfare. The light of facts, however,—
must make it plain to any impartial observer, that a reasoning will and
purpose are needed to make a new social order, and are imperatively
demanded by the forces at work in mankind’s historic evolution.
When one considers the work that a man does for the body social by means
of his physical labour-power, it is plain that the above reflections are
grounded in the actual life of men. The position which labour has come to
occupy in the social order under the capitalistic form of economy, is such,
that is purchased by the employer from the employed as a commodity. An
exchange is effected between money (as representing commodities) and
labour. But in reality no such exchange can take place; it only appears to do
so.2 What really happens is, that the employer receives in return from the
worker commodities that cannot exist, unless the worker devotes his labour-
power to creating them. The worker receives one part, the employer the
other part of the commodity so created. The production of the commodity is
the result of a co-operation between employer and employed. The product
of their joint action is that which first passes into the circuit of economic
life. For the product to come into existence, there must be a “relation in
right” between worker and “enterpriser”; but the capitalist type of economy
is able to convert this “rights” relation into one determined by the
employer’s superiority in economic power over the employed. In a healthy
social order, it will be obvious that labour cannot be paid for, that one
cannot set an economic value upon it comparable to the value of a
commodity. The commodity produced by this labour first acquires an
economic value by comparison with other commodities. The kind of work a
man must do for the maintenance of the body social, how he does it, and the
amount, must be settled according to his abilities and the conditions of a
decent human existence. And this is only possible when such questions are
settled by the political state, quite independently of the provisions and
regulations made in the economic life.
Thus economic life has its conditions fixed on two sides. On one, there is
the “nature-basis,” which man must take as he finds it; on the other, will be
the “rights-basis” which has to be created on the free and independent
ground of the political State,—detached from economic life, and out of the
common sense of right.
There is, however, another element again, which enters into everything that
is contributed towards the organisation of social life, whether by the
economic life or by the “rights-consciousness.” This element comes from a
third source: the personal abilities of the individual. This third domain
includes everything from the loftiest achievements of the human mind to
that element in all the works of men which comes from their bodily ability
to render greater or less service to the body social. A healthy social
organism must necessarily receive and assimilate whatever comes from this
source in quite a different manner from what comes to it from the life of the
State or that finds expression in the interchange of commodities. To absorb
this element healthily into social life can only be done in one way, and that
is, by leaving it entirely to men’s free receptivity and to the impulses which
personal ability itself brings with it. What is performed at the promptings of
personal ability, loses to a great extent the very groundwork of its existence,
when subjected to artificial influences from the State organisation or from
the economic system. For the only true groundwork of such performances
lies in that inherent force that finds its evolution through human
performance itself. If again the way in which such individual performances
are taken up into the body social directly depends on the economic life,—or
if the State organises it,—there is then a check upon that free spontaneous
receptivity, which is the only sound and wholesome channel for their
reception. For the spiritual life of the body social, there is but one possible
line of healthy evolution;—and it must not be forgotten, by what
innumerable fine threads this spiritual life is connected with the evolution
of all other individual potentialities in human life. What it does, must be the
outcome of its own impulses; and those who receive its services must be
closely bound up with it in sympathy and understanding. Such, as here
sketched, are the requisite conditions for a sound evolution of the spiritual
life of the body social. What prevents them from being clearly perceived, is
that people’s eyes are blurred through constantly seeing the spiritual life in
great part fused and confounded with the political State system. The fusion
has been taking place through several hundreds of years, and they have
grown accustomed to it. They talk, it is true, about “freedom of knowledge”
and “freedom of education”; but, all the same, they consider it a matter of
course that the political State should have control of this “free” knowledge
and “free” education. They do not see nor feel, how in this way the state is
bringing all spiritual life into dependence on state requirements. The notion
is, that the State provides the educational posts, and that the spiritual life
then unfolds “freely” under the hands of the people who fill these State
posts. Through long thinking in this way, people come to forget what an
intimate connection there is between the inmost nature of man and the
substance of the spiritual life growing up within him, and how impossible it
is for the growth of this spiritual substance to be really free, if it owes its
place in the body social to any other impulses than those alone which
proceed from the spiritual life itself. Science, with all that part of spiritual
life which it affects, has received its whole cast from the fact of its
management forming part of the State system in recent centuries. And not
only so, but this fusion with the State has set its stamp on the substance of
science as well. Of course, the results of mathematics or physics cannot be
directly influenced by the State. But consider history and other subjects of
general culture:—Have not they come to reflect the connection of their
professional representatives with the State system?—to be an obedient
mirror of State requirements?
Both the political State and the economic system will obtain from the body
spiritual, when under its own self-administration, that steady inflow from
the spiritual life, of which they are in need. Practical training too for
economic life will for the first time fully develope its full possibilities,
when the economic system and the body spiritual can co-operate in
freedom. People will come with a suitable training into the economic field
and will put life into all they meet with there, through the strength that
comes from spiritual endowment set free from restraint. And people, who
have won their experience in the economic field, will find their way into the
spiritual organisation, and help to fertilise what there needs fertilising.
The effect within the political State of spiritual abilities being left free, will
be the growth of sane and sound views, such as are needed in this field. The
man who works with his hands will be able to feel contented with the place
his own labour fills in the body social. He will come to realise that the body
social cannot float him, unless his hand-work has the guidance requisite for
its organisation. He will acquire a sense of the solidarity of his own labour
with those organising forces which he can trace to the development of
personal talent. The political State will afford him a ground on which he can
establish the “rights” that secure to him his share in the proceeds of the
commodities he produces; and he will freely allot to the spiritual property,
from which he benefits, a portion sufficient to keep it productive. There will
be a possibility for producers in the spiritual field, too, to live on the
proceeds of their work. What anyone chooses to do in the matter of spiritual
work, will be nobody’s affair but his own; but for any service he may render
to the body social he will be able to count on willing recompense from
people to whom spiritual goods are a necessity. Anyone, who is not satisfied
with the recompense he receives under the spiritual organisation, must have
recourse to one of the other fields, either to the political state, or to
economic life.
Into the economic life pass those technical ideas which originate in the
spiritual life. Their origin is in the spiritual life, even although they proceed
directly from persons belonging to the State or to the economic world. In
the spiritual life originate all those ideas and organising capacities that
enrich the life of the State and of industrial economy. For everything thus
supplied to both these fields of social life from the spiritual source, the
recompense will either, as in the other cases, be raised through voluntary
recognition on the part of those who directly draw from this source, or else
it will be regulated by the “rights” that gradually become built up in the
political sphere. What the political State itself needs for its own
maintenance, will be raised by a system of taxation, which will be the
outcome of a harmonious co-ordination of the claims of economic life, on
the one hand, and those of the “rights-consciousness” on the other.
Alongside the political sphere and the economic sphere in a healthy society,
there must be the spiritual sphere, functioning independently on its own
footing. The whole trend of the evolutionary force of modern mankind is in
the direction of this threefolding of the social organism. So long as the life
of the community could be guided in all essentials by the instinctive forces
at work in the mass of mankind, so long there was no urgent tendency
towards this definite separation into three functions. At bottom, there were
always these three distinct sources; but in a yet dim and dully conscious
social life they worked together as one. Our modern age demands conscious
co-operation on the part of man, and that he should take his place open-
eyed in the workings of the body social. This new social consciousness
must, however, be directed from three aspects, if it is to shape men’s life
and conduct healthily. It is this threefold line of evolution towards which
modern humanity is striving in the soul’s unconscious depths; and what
finds outlet in the social movement is but the stormy light cast up from the
fires below.
These three ideals appear contradictory, until one perceives the necessity for
establishing a threefold order of society; and then their real meaning for
social life first becomes apparent. The three divisions must not be
artificially dovetailed together and centralised under some theoretical
scheme of unity, parliamentary or other. They must be one living reality.
Each of the three branches of the body social must centre in itself; and the
unity of the whole will first come about through the workings of the three,
side by side and in combination. For in actual life it is the apparent
contradictories that make up a unity. Accordingly, one will come to
comprehend what the life of the body social is, when one fully perceives the
part played by these three principles of brotherhood, equality and freedom
in a real, workable form of society. It will then be recognised, that men’s
co-operation in economic life must rest on that brotherhood that springs out
of the Associations. The second system is that of “common rights,” where
one is dealing with purely human relations between one person and another;
and here one must strive to realise the idea of equality. Whilst in the
spiritual field, which stands comparatively alone within the body social, it
is the idea of freedom that needs to be realised. Seen in this way, these three
ideals reveal their value for real existence. Thy cannot find their realisation
in a chaotic stream of social life, but only in the threefold working of a
healthy social organism. No social state, constructed on an abstract
centralised scheme, can carry freedom, equality and brotherhood pall mall
into practice. But each of the three branches of the body social can derive
its strength from one of these ideal impulses; and then all three branches
will work fruitfully in conjunction.
Those people who, at the end of the eighteenth century, first demanded the
recognition of these three ideas, Freedom, Equality, Brotherhood, and those
who took up the cry again later on,—they had already a dim sense of
whither the forces of human evolution were tending in modern times. But
they had not got beyond belief in the onefold State. And in the onefold State
these ideas involve a contradiction. They pinned their faith to the
contradiction, because, deep-down in the sub-conscious depths of their
souls, there was this striving towards the threefold order of society, in
which their trinity of ideas can actually achieve a higher unity. To lay hold
on those evolutionary forces, which through the growth of mankind all
through these latter times, are working towards the threefold order,—to
make of them a conscious social will and purpose,—this is what is
demanded of us at the present day in unmistakeable language by the hard
facts of the social situation.
1 Author’s Note. For the purposes of life, what is wanted in an explanation is not
definitions drawn from theory, but ideas that give a picture of a real live process. As used
in this sense, “commodity” denotes something that plays an actual part in man’s life and
experience. Any other concept of it either omits or adds to this, and so fails to tally exactly
with what really and truly goes on in life. ↑
2 Author’s note. It is quite possible in life for a transaction not only to be interpreted
unreally, but also to take place unreally. Money and labour are not interchangeable values,
but only money and the products of labour. Accordingly, if I give money for labour, I am
doing something that is unreal. I am making a sham transaction. For in reality I can only
give money for the product of labour. ↑
3 Author’s Note. The “rights of the matter” becomes the axiomatic basis for all
economic activity under this relation of labour to the “rights” system; and the associations
will have to accept these as a given premise in economic life. What this does, however, is
to make economic organisation dependent upon man, instead of man being dependent upon
the system of economics. ↑
III.
Capitalism and Social Ideas
(Capital and Human Labour)
To form an opinion as to what the course of action is in the social field,
which the facts of the day are so loudly demanding, is only possible, if one
is willing to be guided in one’s opinion by an insight which goes below the
surface, to the fundamental forces of the social organism. The following
introductory remarks are the outcome of an effort to arrive at such an
insight. Nothing profitable can be done in the present day with social
measures based on opinions that are drawn from a restricted sphere of
observation. The facts that have grown out of the social movement reveal
disturbances at the foundations of the social order, not merely surface ones.
And to cope with these facts one needs an insight that also goes to the root
of things.
At the present moment people are very justly asking: What is the most
immediate step to be taken in order to satisfy the claims that the social
movement has brought to the front? But there is no taking even the most
immediate step to good purpose, without first k n o w i n g how what one is
trying to do is related to the fundamental principles of a healthy social
order. And once one knows this, then, in whatever place one may find
oneself, or whatever place one may select to work in, one will discover the
particular task that requires doing under the circumstances. The obstacle to
acquiring the kind of insight implied here, lies in that element of human
will-power, which during the slow course of years has crystallised into
social institutions. Men have so grown into these institutions, that the
institutions themselves form the standpoint from which they view them and
consider, what to change and what to leave. Their thoughts follow the lead
of the facts, instead of mastering them.
To-day, it is necessary to see, that one cannot form any judgment adequate
to the facts, without going back to those p r i m a l c r e a t i v e
t h o u g h t s which underlie all social institutions. The body social requires
a constant fresh supply of the forces that reside in these primal thoughts;
and if the suitable channels are not there, through which these forces can
flow, then social institutions assume forms which impede life, instead of
furthering it. But although the conscious thoughts of men may go astray,
although they may,—and have,—created facts that impede life, yet these
primal thoughts live on in men’s instinctive impulses. Tumultuously and
destructively they break against the world of established facts that hem
them in; and these primal thoughts it is, which open or disguised, find their
way out in convulsions that threaten to overthrow the social order. Such
revolutionary convulsions will not cease to occur, until the body social
takes a form, in which there may be always both an inclination to notice
when any institution is beginning to deviate from its first intention in those
primal thoughts, and at the same time the possibility of counter-acting every
such deviation before it becomes strong enough to be a danger. In our times,
the actual conditions, throughout a wide range of human life, have come to
deviate very widely from what the primal thoughts require. And these
primal thoughts, as they live on in the impulses of the human soul, are a
commentary,—a commentary that voices itself loudly enough in facts,—of
what has been taking shape in the body social during the last few centuries.
What is wanted, is good will and vigorous resolution to turn again to these
primal thoughts. We must not be blind to the mischief that is done,
especially at this moment, by dismissing these primal thoughts from the
field of actual life as “unpractical generalities.” The facts of life itself, and
the claims of the working-class masses, afford a practical commentary on
what the modern age has made of the body social. The task of our age, in
face of these facts, is not merely to criticise, but to set about remedying
them; which means going to the primal thoughts for the direction in which
we must now consciously guide them. For the time is gone by, when the old
instinctive guidance could suffice for mankind; what it could accomplish up
till now, is now no longer enough.
One of the main questions raised by the practical criticisms of the times is
this:—How is a stop to be put to the oppression which working-class
humanity suffers under private capitalism. The owner, or controller, of
capital is in a position to press other men’s bodily labour into the service of
any work he takes on hand? In the social relation that arises in the co-
operation of capital and human labour-power, there are three elements to be
distinguished: the enterprising activity, which must rest on the basis of
individual ability in some one person or group of persons;—the relation of
the “enterpriser” to the worker, which must be a “relation in right”;—and
the production of an object which acquires a commodity value in the circuit
of economic life. For the “enterprising” activity to find its scope in a
healthy way in the social order, there must be forces at work in social life
which afford men’s individual abilities the best possible mode of
manifesting themselves; and therefore there must be one province of the
body social which secures a person of ability free occasion for the
employment of his abilities, and makes it possible to leave the estimation of
their value to other people’s free and voluntary understanding.
It is only the lack of freedom in spiritual life, which has kept its social
character in abeyance. The fashion in which the forces of social life have
found expression amongst the leading classes, has restricted their use and
value to limited circles of mankind, in a way which is anti-social. What was
produced in these circles could only be brought artificially within reach of
working-class mankind. This section of mankind could draw no strength for
the support of their souls from this spiritual life; for they had no real part
nor property in it. Schemes for “popular instruction,” for “the uplifting of
the masses,” “Art for the People,” and so forth,—all such things are not
really the means of spreading spiritual property amongst the people, whilst
spiritual property keeps the character it has acquired in recent times. For
“the people,” as regards their inmost life and being, are not in it. All that it
is possible to give them, is as it were a bird’s-eye view of these spiritual
treasures from a point outside. And if this is true of spiritual life in its
narrower sense, it has also its meaning for those offshoots of spiritual
activity, which find their way into economic life on the basis of capital. In a
sound order of society, the worker will not stand at his machine, and come
into contact with nothing but its mechanism; whilst the capitalist alone
knows what is the destiny of the manufactured commodities in the round of
economic life. The workman must share fully in the whole concern, and be
able to form a distinct conception of the part that he himself is playing in
social life through his work in making the commodity. The enterpriser must
hold regular conferences, with the object of arriving at a common field of
ideas that shall include both employers and employed. Such conferences
must be regarded as being as much a part of the business as the actual work.
This is a healthy way of conducting business, and one that will arouse in the
workers a sense, that by the control of capital, if he uses it properly, a
person benefits the whole community,—including the worker, as a member
of it. The above-board dealing, necessary to a willing understanding on the
part of others, will make the “enterpriser” careful to keep his business
methods above suspicion.
All this will not seem negligible to anyone with a sense for the social effects
of that inner community of feeling and experience, which arises from the
prosecution of a common task. Those who possess this sense, will clearly
perceive, how greatly it is to the benefit of economic activity that the
direction of economic affairs, based on capital, should come from the
spiritual life, and have its roots in the spiritual domain. This preliminary
condition must be fulfilled, before people’s present interest in capital and in
increasing it simply for the sake of profits, can give place to an interest in
the actual business of production and the doing of the job on hand.
Persons of a socialist turn of mind at the present day aim at bringing the
means of production under the control of the community. What is right and
desirable in their aims can only be achieved if this control is exercised
through the free spiritual domain. Such control through the free spiritual
domain will do away with all possibility of that economic coercion, which
brings with it such a sense of degradation, and which the capitalist exerts
when his capitalist activities are born and bred of the forces of economic
life; and it will also prevent that crippling of men’s individual abilities,
which inevitably results when these abilities are directed by the political
State.
Social arrangements on the lines here proposed will lay the basis for a really
free contractual relation between the work-director and the work-doer,—a
relation resting not on barter of commodities (or money) for labour-power,
but on an agreement as to the share due to each of the two joint authors of
the commodity.
The sort of service, that is rendered to the body social on the basis of
capital, depends of its very essence on the part played in it by men’s
individual abilities. Nothing but the free spiritual life can give men’s
abilities the impulse they need for their development. Even in a society,
where the development of individual ability is tied up with the
administration of the political State, or to the forces of economic life, even
there, real productivity, in everything requiring the expenditure of capital
depends on as much of free individual power as can find its way through
the shackles imposed upon it. Only, under such conditions, the development
is an unhealthy one. It is not the free development of individual ability,
exercised on a basis of capital, that has brought about conditions under
which human labour-power can be nothing but a commodity; it is the
shackling of these powers through the political life of the State or in the
circuit of economic processes. An unprejudiced recognition of this fact is at
the present day a necessary first step to everything that has to be done in the
field of social organisation. For the superstition has grown up in modern
times, that the measures needed for the welfare of society must come from
either the political State or the economic system. And if we pursue any
further the road along which this superstition has started us, we shall set up
all manner of institutions, that, far from leading man to the goal towards
which he is striving, will increasingly aggravate the oppressive conditions
from which he is seeking to escape.
At the time when people first began to think about the question of
capitalism, this same capitalism had already set up a disease in the body
social. The disease is what people feel and are aware of. They see that it is
something which has to be counteracted. But one must see further than that;
one must recognise, that the origin of the disease lies in the fact, that the
creative forces, at work in capital, have been absorbed into the circuit of
economic life. If one is to work in the direction already urgently demanded
by the evolutionary forces of mankind, one must not suffer oneself to be
deluded by the type of thought, which regards as an unpractical piece of
idealism the demand, that the spiritual life should be set free, and given
control of the employment of capital.
At the present moment, certainly, people seem but little disposed to connect
the spiritual life in any way directly with that social idea, which is to put
capital on sound lines. They try to connect onto something that falls within
the circuit of economic life. They see, that the manufacture of commodities
in recent times has led to wholesale dealing, and this again to the present
form of capitalism. And now they propose to replace this form of industrial
economy by a syndical system, under which the producers will be working
for their own wants. But since of course industry must retain all the modern
means of production, the various industrial concerns are to be united
together into one big syndicate. Here, they think, everyone will be
producing to the orders of the community, and the community cannot be an
exploiter, because it would simply be exploiting itself. And for the sake, or
from the necessity, of linking onto something that already exists, they turn
their eyes on the modern State, with a view to converting this into a
comprehensive syndicate. One thing however they leave out of their
reckoning, namely, that the bigger the syndicate the less possibility there is
of its being able to do what they expect of it. Unless individual ability finds
its place in the syndical organism in the manner and form already described,
it is impossible that communal control of labour should result in a healthy
commonwealth.
These currents of thought tend more or less unconsciously away from all
that gives due energy and driving power to the inward life. They make for a
conception of life,—an inner life of thought, of soul, directed to the pursuit
of knowledge,—which shall be as it were an island in the common sea of
human existence. Thus they are not in a position to build the bridge between
this inner life and that other which binds men to the everyday world. It is
not uncommon to-day, to find persons who think it rather “distinguished” to
sit aloft in castles of cloudland, meditating in somewhat pedantic
abstractness over all manner of ethico-religious problems. One finds them
meditating on virtue and how a man may best acquire it; how he should
dwell in loving-kindness towards his neighbours, and how he may be so
blessed as to find “a meaning in life.” And, all the time, one recognises the
impossibility of bridging the gulf between what these folks call good, and
sweet, and kindly, and right, and proper, and all that is going on in the outer
world amongst men’s everyday surroundings, in the manipulation of capital,
the payment of labour, the consumption, production and circulation of
commodities, the system of credit banking, and the stock-exchange. One
can see two main streams running side by side even in men’s very habits of
thought, one of which remains up aloft as it were in divine spiritual
altitudes, and has no desire to build a bridge from spiritual impulses to life’s
ordinary affairs. The other stream runs on, void of thought, in the everyday
world. But life is a single whole. It cannot thrive unless the forces that
dwell in all ethical and religious life bring driving power to the most
commonplace, everyday things of life, into the sort of life that some persons
may think rather beneath them. For, if people neglect to build the bridge
between the two regions of life, then not only their religious and moral life,
but their social thinking too, degenerates into mere wordy sentiment, far
removed from commonplace, true realities. And then these commonplaces
have their revenge as it were. For there is then still a sort of “spiritual”
impulse in man, urging him in pursuit of every imaginable ideal and every
conceivable thing that he calls “good”; whilst on the other side there are
those different instincts, which are in opposition to these ideals,—the
instincts that underlie the ordinary daily needs of life and require an
economic system for their satisfaction, and to which he devotes himself
minus his spirit. He knows no practicable path from his conception of
spirituality to the business of everyday life. And so everyday life acquires a
form, which is not even supposed to have any connection with those ethical
impulses that remain aloof in the more distinguished altitudes, all soul and
spirit. And then, the daily commonplaces are avenged; for the ethical
religious life turns to a living lie in men’s hearts, because, all unperceived it
is being dissevered from commonplace practice and from all direct contact
with life.
How many people there are to-day, who, from a certain ethical or religious
distinction of mind, have all the will to live on a right footing with their
fellow-men, who desire to act by others only in the best conceivable way,
and yet fall short of the kind of feeling that would enable them to do so,
because they cannot lay hold upon any social conception that finds its outlet
in practical habits of life! It is people such as these, who, at this epoch-
making moment in the world’s history when social questions have become
so urgent, are blocking the road to a true practice of life. They reckon
themselves very practical persons, and all the time are visionary
obstructionists. One can hear them making speeches like this: “What is
really needed, is for people to rise above all this materialism, this external
material life which drove us into the disaster of the great war and into all
this misery. They must turn to a spiritual conception of life.” And to
illustrate man’s path to spirituality, they are forever harping upon great men
of byegone days, who were venerated for their conversion to a spiritual way
of thinking. One finds, however, that directly one tries to bring the talk
round to the very thing that the spirit has to do for real practical life, and
what is so urgently required of the spirit to-day: the creation of daily bread,
one is at once reminded, that the first thing, after all, is to bring people
again to acknowledge the spirit. At this moment however, the urgent thing
is, to employ the powers of the spiritual life to discover the right principles
of social health. And for this it is not enough that men should make a hobby
of the spirit, as a bye-path in life. Everyday existence needs to be brought
into line with the spirit. It was this taste for turning spiritual life into bye-
paths, that led the late ruling classes to find their pleasure in social
conditions that ended in the present state of affairs.
In the social life of the present day, the control of capital for the production
of commodities is very closely bound up with the ownership of the means
of production, amongst which capital is of course included. And yet these
two relations between man and capital are quite different as regards the way
they operate within the social system. The control of capital by individual
ability is, when suitably applied, a means of enriching the body social with
wealth which it is to everyone’s interest should exist. Whatever a person’s
position in life, it is to his interest that nothing should be wasted of those
individual abilities which flow from the fountain-head of human nature, and
through which things are created that are of use to the life of man. These
abilities, however, never become developed, unless the human beings
endowed with them have free initiative in their exercise. Any check to the
free flow from these sources means a certain measure of loss to the welfare
of mankind. Now capital is the means of making these abilities available for
extended fields of social life. It must be to the true interests of everybody in
a community to have the collective property in capital so administered, that
individuals specially gifted in one direction, or groups of people with
special qualifications, should be able to acquire the use of capital, and
should use it in the way their own particular initiative prompts them.
Everybody, be he brainworker or labourer, if he consults his own interests
without prejudice, must say: “I should not only wish an adequate number of
persons, or groups of persons, to have absolutely free use of capital, but I
should also like them to have access to capital on their own initiative; for
they themselves are the best judges of how their particular abilities can
make capital a means of producing what is useful to the body social.”
It does not fall within the scope of this work to describe how, in the course
of mankind’s evolution, as individual human abilities came to play a part in
the social order, private property also grew up out of other forms of
ownership. Ownership has, under the influence of the division of labour,
gone on developing in this form within the body social down to the present
day. And it is with present conditions that we are here concerned, and with
what the next stage in their evolution must be. But in whatever way private
property arose,—by the exercise of power, conquest, etc.,—it is an outcome
of the social creativeness which is associated with individual human ability.
And yet socialists to-day, with their thoughts bent upon social
reconstruction, hold the theory, that the only way to obviate what is
oppressive in private ownership, is to turn it into communal ownership.
They put the question thus: How can private property in the means of
production be prevented from arising, so that its oppressive effect upon the
unpropertied masses may cease? In putting the question in this way, they
overlook the fact, that the social organism is something that is constantly
changing, growing. One cannot ask about a growing organism. What is the
best form of arrangement to preserve it in the state which one regards as the
suitable one for it. One can think in that way about something which starts
at a certain point and then goes on in the same way ever afterwards without
any essential change. But that will not do for the body social. Its life is a
continual changing of each thing as it arises. To fix on some form as the
very best, and expect it to remain in that form, is to undermine the very
conditions of its life.
One of the conditions of life for the body social is, that whoever can serve
the community through his individual abilities should not be deprived of the
power to do so freely of his own initiative. Where such service involves free
use of the means of production, to hamper free initiative would be to injure
the general social interests. I am not proposing here to urge the argument
commonly used in this connection, namely, that the prospect of the gains
associated with the ownership of means of production is needed in order to
stimulate the “enterpriser” to exertion. The whole form of thought
represented in this book, with its conception of a progressive evolution in
social conditions, must lead to the expectation, that this kind of incentive to
social activity may be eliminated, through the emancipation of the spiritual
life from its association with the political and economic system. Once it is
free, the spiritual life will of itself inevitably evolve a social sense; and this
social sense will provide incentives of a very different kind from the hope
of economic advantage. But it is not so much a question of the kind of
impulse which makes men like private ownership of the means of
production, as of whether the necessary conditions of life for the body
social are best fulfilled when the use of the means of production is free, or
when it is directed by the community. And here, one must always clearly
remember, that one cannot draw conclusions for the social organism of the
present day from the conditions of life supposed to be found in primitive
communities, but from such only as correspond to man’s present stage of
development. At the present stage, it is not possible for individual ability to
find fruitful exercise through capital in the round of economic life, unless
its use of capital is free. For fruitful results in any field of production there
must be opportunity for the free use of capital; not because it gives an
advantage to some individual or group; but because, opportunely directed
by a social sense, it is the best way of serving the community. Whether he is
producing alone or in company, the material a man is working on is in a
manner bound up with himself, much like the skill of his own arms or legs.
To interfere with his free use of the means of production, is like crippling
the free exercise of his bodily skill. Private ownership, however, is simply
the medium for this free use of the means of production. As regards
ownership, all that matters to the body social, is that the owner should have
the r i g h t to use it of his own free initiative. Clearly, two things are joined
together in social life, that are of quite distinct implications for the body
social—one, the free use of the capital basis of social production; the other,
the “relation in right” which arises between the user of capital and other
people, from the fact that his right of use precludes these other people from
free activity on this same capital basis.
It is not the free use of itself in the beginning, which does the mischief in
society, but the continuance of the right of use after the circumstances have
come to an end which linked that use opportunely to individual abilities.
Anyone who looks upon the social organism as a changing, growing thing,
cannot fail to see what is meant. He will look about for some possible mode
of arranging what is helpful to life in one way, so that it may not have bad
effects in another. For a live thing, there is no possible mode of
arrangement, that can lead to fruition, in which the finished process in its
growth will not in turn become detrimental. And if one is oneself to
collaborate at a growing organism,—as man necessarily must in the body
social,—one’s business cannot lie in checking necessary developments, for
the sake of obviating detrimental consequences. That would be to sap every
possibility of life for the body social. It is solely a question of intervening at
the right moment, when what was helpful and opportune is beginning to
turn detrimental.
In this latter case, what is so earned, as well as all savings that spring from
the results of a person’s own work, will remain until the owner’s death, or
some later date, in the private possession of the earner or his descendants.
Until this date also, these savings will draw an interest from the person who
is given them to procure the means of production. The amount of the
interest will be the outcome of the general “rights-consciousness,” and be
fixed by the “rights-State.” In a social order, based on the principles here
described, it will be possible to effect a complete distinction between
proceeds that are due to the employment of means of production, and sums
accumulated through the earnings of personal labour, spiritual or physical.
It is in accordance with the common sense of right, as well as to the general
social interest, that these two things should be kept distinct. What a person
saves and places at the disposal of a productive industry, is a service
rendered to the general interests, inasmuch as it makes it possible in the first
place for personal ability to direct production. But where, after deducting
the rightful interest, there is an increase on the capital, arising out of the
means of production, such increase is due to the collective working of the
whole social organism, and must accordingly flow back into it again in the
way above described. All that the “rights-State” will have to do, is to pass a
resolution, that the capital accumulations in question are to be transferred in
the prescribed way. It will not be called on to decide, which material or
spiritual branch of production is to have the disposal either of capital so
transferred or of capital savings;—for this would lead to the State
tyrannising over spiritual and material production, which are best directed
for the body social by men’s individual abilities, as has been shewn. But it
will be open to anyone to appoint a corporate body of the spiritual
organisation to exercise the right of disposal over capital that he has
created, if he does not want himself to select his successor.
Property acquired through saving, together with the interest on it, will also
pass at the earner’s death, or a while later, to some person or group actively
engaged in spiritual or material production,—but only to a producer, not to
be turned into an income by someone who is not producing. The choice will
be made by the earner in his last will. Here again, if no person or group can
be chosen direct, it will be a question of transferring the right of disposal to
a corporation of the spiritual system. Only when a person himself makes no
disposition of his savings, then the “rights-State” will act on his behalf, and
require the spiritual organisation to dispose of them.
Through social institutions of this kind, personal and family feelings will
admit of being brought into harmony with the claims of general humanity. It
may of course be pointed out, that there will be a great temptation for
people to transfer their property during their life-time to their descendants,
or to some one of them, and that it is quite easy to give such a person the
appearance of a producer, whilst all the while he may be quite incompetent
compared to others, who would be much better in his place. The temptation
to do this, can however be reduced to a minimum under social institutions
of the above kind. The “rights-State” has only to require, that property,
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookmasss.com