100% found this document useful (1 vote)
8 views

Game Programming with Unity and C#: A Complete Beginner's Guide, 2nd Edition Casey Hardman instant download

The document provides links to download various ebooks and textbooks, including 'Game Programming with Unity and C#: A Complete Beginner's Guide, 2nd Edition' by Casey Hardman. It features additional titles related to programming and cryptography, with direct URLs for each book. The content also includes copyright information and details about the publisher, Apress Media LLC.

Uploaded by

gulyayesmar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
8 views

Game Programming with Unity and C#: A Complete Beginner's Guide, 2nd Edition Casey Hardman instant download

The document provides links to download various ebooks and textbooks, including 'Game Programming with Unity and C#: A Complete Beginner's Guide, 2nd Edition' by Casey Hardman. It features additional titles related to programming and cryptography, with direct URLs for each book. The content also includes copyright information and details about the publisher, Apress Media LLC.

Uploaded by

gulyayesmar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

Download the full version and explore a variety of ebooks

or textbooks at https://ebookmass.com

Game Programming with Unity and C#: A Complete


Beginner's Guide, 2nd Edition Casey Hardman

_____ 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/

Access ebookmass.com now to download high-quality


ebooks or textbooks
We have selected some products that you may be interested in
Click the link to download now or visit ebookmass.com
for more options!.

Pro Cryptography and Cryptanalysis with C++23: Creating


and Programming Advanced Algorithms 2nd Edition Marius
Iulian Mihailescu
https://ebookmass.com/product/pro-cryptography-and-cryptanalysis-
with-c23-creating-and-programming-advanced-algorithms-2nd-edition-
marius-iulian-mihailescu-2/

Pro Cryptography and Cryptanalysis with C++23: Creating


and Programming Advanced Algorithms, 2nd Edition Marius
Iulian Mihailescu
https://ebookmass.com/product/pro-cryptography-and-cryptanalysis-
with-c23-creating-and-programming-advanced-algorithms-2nd-edition-
marius-iulian-mihailescu/

Pro Cryptography and Cryptanalysis with C++23: Creating


and Programming Advanced Algorithms 2nd Edition Marius
Iulian Mihailescu
https://ebookmass.com/product/pro-cryptography-and-cryptanalysis-
with-c23-creating-and-programming-advanced-algorithms-2nd-edition-
marius-iulian-mihailescu-3/

Programming for Game Design: A Hands-On Guide with Godot


1st Edition Wang

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/

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/

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/

C Programming Language: C PROGRAMMING LANG _p2 2nd


Edition, (Ebook PDF)

https://ebookmass.com/product/c-programming-language-c-programming-
lang-_p2-2nd-edition-ebook-pdf/

Options and Derivatives Programming in C++23: Algorithms


and Programming Techniques for the Financial Industry, 3rd
Edition Carlos Oliveira
https://ebookmass.com/product/options-and-derivatives-programming-
in-c23-algorithms-and-programming-techniques-for-the-financial-
industry-3rd-edition-carlos-oliveira/
Game Programming
with Unity and C#
A Complete Beginner’s Guide

Second Edition

Casey Hardman
Game Programming with
Unity and C#
A Complete Beginner’s Guide

Second Edition

Casey Hardman
Game Programming with Unity and C#: A Complete Beginner’s Guide, Second Edition
Casey Hardman
West Palm Beach, FL, USA

ISBN-13 (pbk): 978-1-4842-9719-3 ISBN-13 (electronic): 978-1-4842-9720-9


https://doi.org/10.1007/978-1-4842-9720-9

Copyright © 2024 by Casey Hardman


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Spandana Chatterjee
Development Editor: James Markham
Editorial Assistant: Jessica Vakili
Cover image from Freepik
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole
member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc
is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub. For more detailed information, please visit https://www.apress.com/gp/services/
source-code.
Paper in this product is recyclable
Table of Contents


■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

Using the Constructor��������������������������������������������������������������������������������������������������������������������������� 74


Static Members������������������������������������������������������������������������������������������������������������������������������������ 75

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

Player Controls����������������������������������������������������������������������������������������������������������������������������������� 106


Death and Respawn��������������������������������������������������������������������������������������������������������������������������� 108
Levels������������������������������������������������������������������������������������������������������������������������������������������������� 108
Level Selection����������������������������������������������������������������������������������������������������������������������������������� 108
Obstacles�������������������������������������������������������������������������������������������������������������������������������������������� 108

Project Setup���������������������������������������������������������������������������������������������������������������� 109


Summary���������������������������������������������������������������������������������������������������������������������� 110

■Chapter 14: Player Movement��������������������������������������������������������������������������� 111
Player Setup����������������������������������������������������������������������������������������������������������������� 111
Materials and Colors���������������������������������������������������������������������������������������������������� 113
Applying Materials������������������������������������������������������������������������������������������������������������������������������ 116

Declaring Our Variables������������������������������������������������������������������������������������������������ 117


Properties��������������������������������������������������������������������������������������������������������������������� 118
Tracking the Velocity���������������������������������������������������������������������������������������������������� 119
Applying the Movement������������������������������������������������������������������������������������������������ 124
Summary���������������������������������������������������������������������������������������������������������������������� 127

■Chapter 15: Death and Respawning������������������������������������������������������������������ 129
Enabling and Disabling������������������������������������������������������������������������������������������������� 130
Death Method��������������������������������������������������������������������������������������������������������������� 131
Respawn Method��������������������������������������������������������������������������������������������������������� 132
Summary���������������������������������������������������������������������������������������������������������������������� 134

■Chapter 16: Basic Hazards�������������������������������������������������������������������������������� 135
Collision Detection�������������������������������������������������������������������������������������������������������� 135
Hazard Script���������������������������������������������������������������������������������������������������������������� 139
Projectile Script������������������������������������������������������������������������������������������������������������ 141
Shooting Script������������������������������������������������������������������������������������������������������������� 144
Summary���������������������������������������������������������������������������������������������������������������������� 146

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

Sorting Patrol Points���������������������������������������������������������������������������������������������������� 163


Moving the Patroller����������������������������������������������������������������������������������������������������� 166
Summary���������������������������������������������������������������������������������������������������������������������� 170

■Chapter 19: Wandering Hazards������������������������������������������������������������������������ 171
Wander Regions����������������������������������������������������������������������������������������������������������� 171
Wanderer Setup������������������������������������������������������������������������������������������������������������ 174
Wanderer Script����������������������������������������������������������������������������������������������������������� 174
Handling the State������������������������������������������������������������������������������������������������������������������������������ 175
Reacting to the State�������������������������������������������������������������������������������������������������������������������������� 177

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

Prefabs and Variants���������������������������������������������������������������������������������������������������� 189


Making Levels�������������������������������������������������������������������������������������������������������������� 190
Adding Walls����������������������������������������������������������������������������������������������������������������� 191
Level View Camera������������������������������������������������������������������������������������������������������� 192
Summary���������������������������������������������������������������������������������������������������������������������� 192

■Chapter 22: Menus and UI��������������������������������������������������������������������������������� 193
UI Solutions������������������������������������������������������������������������������������������������������������������ 193
Immediate Mode GUI (IMGUI)�������������������������������������������������������������������������������������������������������������� 193
Unity UI (uGUI)������������������������������������������������������������������������������������������������������������������������������������� 193
UI Toolkit��������������������������������������������������������������������������������������������������������������������������������������������� 194

Scene Flow������������������������������������������������������������������������������������������������������������������� 194


Level Selection Script��������������������������������������������������������������������������������������������������� 196
Summary���������������������������������������������������������������������������������������������������������������������� 200

■Chapter 23: In-Game Pause Menu��������������������������������������������������������������������� 203
Freezing Time��������������������������������������������������������������������������������������������������������������� 203
Summary���������������������������������������������������������������������������������������������������������������������� 207

■Chapter 24: Spike Traps������������������������������������������������������������������������������������ 209
Designing the Trap�������������������������������������������������������������������������������������������������������� 209
Raising and Lowering��������������������������������������������������������������������������������������������������� 212
Writing the Script��������������������������������������������������������������������������������������������������������� 213
Adding Collisions���������������������������������������������������������������������������������������������������������� 217
Summary���������������������������������������������������������������������������������������������������������������������� 217

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

Upper Classes�������������������������������������������������������������������������������������������������������������� 260


Arrow Towers��������������������������������������������������������������������������������������������������������������� 260
Summary���������������������������������������������������������������������������������������������������������������������� 266

■Chapter 30: Build Mode UI��������������������������������������������������������������������������������� 267
UI Basics����������������������������������������������������������������������������������������������������������������������� 268
The RectTransform������������������������������������������������������������������������������������������������������� 270
Building Our UI������������������������������������������������������������������������������������������������������������� 272
Summary���������������������������������������������������������������������������������������������������������������������� 277

■Chapter 31: Building and Selling����������������������������������������������������������������������� 279
Events��������������������������������������������������������������������������������������������������������������������������� 279
Setting Up��������������������������������������������������������������������������������������������������������������������� 280
Build Mode Logic���������������������������������������������������������������������������������������������������������� 283
The Dictionary�������������������������������������������������������������������������������������������������������������� 288
OnClick Event Methods������������������������������������������������������������������������������������������������ 290
Summary���������������������������������������������������������������������������������������������������������������������� 296

■Chapter 32: Play Mode Logic����������������������������������������������������������������������������� 297
Spawn and Leak Points������������������������������������������������������������������������������������������������ 297
Locking the Play Button����������������������������������������������������������������������������������������������� 298
Pathfinding Setup��������������������������������������������������������������������������������������������������������� 299
Finding a Path�������������������������������������������������������������������������������������������������������������� 303
Summary���������������������������������������������������������������������������������������������������������������������� 306

■Chapter 33: Enemy Logic����������������������������������������������������������������������������������� 309
Play Mode Setup���������������������������������������������������������������������������������������������������������� 309
Spawning Enemies������������������������������������������������������������������������������������������������������� 313
Enemy Movement��������������������������������������������������������������������������������������������������������� 315
Summary���������������������������������������������������������������������������������������������������������������������� 320

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

Project Setup���������������������������������������������������������������������������������������������������������������� 345


Summary���������������������������������������������������������������������������������������������������������������������� 345

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

Pulling and Pushing������������������������������������������������������������������������������������������������������ 389


Cursor Drawing������������������������������������������������������������������������������������������������������������ 390
Summary���������������������������������������������������������������������������������������������������������������������� 392

■Chapter 41: Moving Platforms��������������������������������������������������������������������������� 393
Platform Movement������������������������������������������������������������������������������������������������������ 393
Platform Detection������������������������������������������������������������������������������������������������������� 396
Summary���������������������������������������������������������������������������������������������������������������������� 398

■Chapter 42: Joints and Swings�������������������������������������������������������������������������� 399
Swing Setup����������������������������������������������������������������������������������������������������������������� 399
Connecting the Joints�������������������������������������������������������������������������������������������������� 404
Summary���������������������������������������������������������������������������������������������������������������������� 406

■Chapter 43: Force Fields and Jump Pads���������������������������������������������������������� 407
Script Setup������������������������������������������������������������������������������������������������������������������ 407
Force Field Setup��������������������������������������������������������������������������������������������������������� 408
Adding Velocity to the Player���������������������������������������������������������������������������������������� 409
Applying Forces������������������������������������������������������������������������������������������������������������ 410
Summary���������������������������������������������������������������������������������������������������������������������� 412

■Chapter 44: Conclusion������������������������������������������������������������������������������������� 413
Physics Playground Recap������������������������������������������������������������������������������������������� 413
Further Learning for Unity�������������������������������������������������������������������������������������������� 414
The Asset Store����������������������������������������������������������������������������������������������������������������������������������� 414
Coroutines������������������������������������������������������������������������������������������������������������������������������������������ 414
Script Execution Order������������������������������������������������������������������������������������������������������������������������ 416

Further Learning for C#������������������������������������������������������������������������������������������������ 416


Delegates�������������������������������������������������������������������������������������������������������������������������������������������� 417
Documentation Comments����������������������������������������������������������������������������������������������������������������� 417
Exceptions������������������������������������������������������������������������������������������������������������������������������������������ 419

xiv
■ Table of Contents

Advanced C#���������������������������������������������������������������������������������������������������������������� 420


Operator Overloading�������������������������������������������������������������������������������������������������������������������������� 420
Conversions���������������������������������������������������������������������������������������������������������������������������������������� 420
Generic Types������������������������������������������������������������������������������������������������������������������������������������� 420
Structs������������������������������������������������������������������������������������������������������������������������������������������������ 421

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

Simon Jackson is a longtime software engineer and architect with many


years of Unity game development experience and is an author of several
Unity game development titles. He loves to create Unity projects and help
educate others, via blogs, vlogs, user groups, or major speaking events.
Currently, his primary focus is the Reality Toolkit project, which is aimed at
building a cross-platform mixed reality framework to enable both VR and
AR developers to build and distribute efficient solutions in Unity.

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

Installation and Setup

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.

Figure 1-1. Download for Windows button

Click this button to download the Unity Hub installer. Once it finishes, run the installer and follow the
prompts.

© Casey Hardman 2024


C. Hardman, Game Programming with Unity and C#, https://doi.org/10.1007/978-1-4842-9720-9_1 3
CHAPTER 1 ■ Installation and Setup

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.

Installing Our Code Editor


You don’t write code in the same sort of software that you might write a book or a resume in. Code editors
are text editors that are fine-tuned for writing code. They have special highlighting for words and symbols,
they know how to format code, and they often come with a slew of features that make it easier and faster for
us to write and work with code.
One such feature is debugging, which is when our code editor “attaches” to Unity while our game is
running. We can then designate points in our code that we want our game to pause upon reaching. This
will freeze the game as it’s running in the Unity editor, as soon as the code hits that point. While the game

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

Unity also supports building to various extended reality (XR) platforms.


As I said, if you need to build to these platforms down the road (we won’t get into them in this book),
then you can always install them through the Hub.
You can also select to install the Unity documentation locally as a module. The documentation can
be immensely helpful. It’s available online as well, and I myself tend to use the online resources, but if you
plan on using Unity offline, you may want to install the documentation so it’s available without an Internet
connection.
Once you’re finished, click the button in the bottom-right corner. If you’ve chosen to add any modules,
that button may say “Continue” to offer further options relating to the chosen modules. If not, it will instead
just say “Install.”
Once it’s done installing, you can now create a Unity project with that version of the engine. Another
nice feature about the Hub is that it will automatically run the correct editor version of Unity when you open
a project (assuming the version is still installed on your computer), so if you have projects spread across
multiple versions of Unity, you don’t have to remember which version of the engine to run – you just start up
the Hub and click on the project you want to open.

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.

Figure 1-3. Dialog box for creating a new Unity project

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.

© Casey Hardman 2024


C. Hardman, Game Programming with Unity and C#, https://doi.org/10.1007/978-1-4842-9720-9_2 9
CHAPTER 2 ■ Unity Basics

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.

Figure 2-4. Creating a Cube using the GameObject menu

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

• The components attached to an individual GameObject are viewed in the Inspector


window. Here, we can customize their functionality by editing fields that relate
to them, such as how bright a light is. Each component is a unique instance with
its own values associated with it, and these values can be customized to provide
different functionality.
• Every GameObject has a Transform, a basic component that resembles a location,
a rotation, and a size. Other component types can be added and removed on the fly
through code, but the Transform cannot – there can only be one per GameObject
and it cannot be deleted.

16
CHAPTER 3

Manipulating the Scene

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)

© Casey Hardman 2024


C. Hardman, Game Programming with Unity and C#, https://doi.org/10.1007/978-1-4842-9720-9_3 17
CHAPTER 3 ■ Manipulating the Scene

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.

Positions and Axes


So how does positioning work in 3D space? It might take a little getting used to, but a position in 3D space is
defined by three number values, referred to as X, Y, and Z.
The X position is right and left.
The Y position is up and down.
The Z position is forward and back.
These positions are often written as (X, Y, Z). For example, (15, 20, 25) would be an X value of 15, a Y
value of 20, and a Z value of 25.
If you have a position of (0, 0, 0), you are at the “world origin,” so to speak – the center of the universe, or
at least the center of the scene.

18
CHAPTER 3 ■ Manipulating the Scene

Add 5 to your X position, and you’ve moved 5 units to the right.


Subtract 5 from your X position, and you’ve moved 5 units to the left.
It works similarly for the Y and Z values: adding moves in one direction, subtracting moves in the
opposite.
Adding to the Y will take you up, and decreasing it will take you down.
Adding to the Z will take you forward, and decreasing it will take you backward.
It is the combination of these three values which defines where something is in the world. Each of
these is called an axis (plural “axes”). So you might hear people say “the X axis” or “the Y axis” or “the X and
Z axes.”
The scale and rotation work in much the same way: they have the same three axes, each one
determining a different direction.
The X scale is the width – left and right.
The Y scale is the height – up and down.
The Z scale is the length – forward and back.
I’m sure you can imagine how rotation works pretty much the same way. The object’s orientation is
defined by three angle values between 0 and 360, which determine how it is turned on each axis.
You’ll notice that the gizmos of the Transform tools that we use to position, rotate, and scale objects (W,
E, and R, respectively) are all color-coded.
The X axis is always red, the Y axis is always green, and the Z axis is always blue.
This is pretty much universally accepted. Get into making 3D models, and you’ll see the same thing –
although some programs consider the Y axis to be forward and back and the Z axis to be up and down,
which is opposite to how Unity does it.

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

Scale and Unit Measurements


Now for the scale. “What is a unit of space?” you might be asking. What does it actually mean when we
change a GameObject’s position from 0 to 1? How much space is that?
This is a slightly confusing concept for some. You probably expect a straight answer. The Unity
developers decided what it is, right? It’s a foot, or maybe a meter – perhaps a yard.
But that’s not how it works. Don’t worry, though. It’s still quite simple: we must decide what a unit is
ourselves. Let’s say we decide that 1 unit is 1 foot. So be it. As long as we follow this in every measurement
we make, then that’s what 1 unit means. We make our people between 5 and 6 units tall, roughly. If we want
something to be just one inch, we make it a twelfth of a unit (roughly 0.083). If we want something to be a
yard, we make it 3 units.
But one more thing we need to note about the scale of a Transform is that the scale is not “how many
units wide, long, and tall something is.” It’s actually a multiplier. It multiplies the size of the mesh (the
3D model).
The mesh itself has its own size, and then the scale value of the Transform just multiplies that size.
This is fine for a cube. The cube mesh is 1 unit wide, tall, and long. So if we set its scale to 5, it’s going to
be 5 times 1 on each axis, so it’s still just 5 units large.
But a plane is trickier. The mesh itself is 10 units wide and long (and it’s paper-thin, so it really has no
height). So when we have a scale of (1, 1, 1) with a plane mesh, it’s actually 10 units wide and long already.
You can see this if you create a Plane and a Cube, leave the scale of each one at the default value of
(1, 1, 1), and position them both in the same place. Note how much larger the Plane is than the Cube, as
shown in Figure 3-2.

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

Parents and Their Children

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.

© Casey Hardman 2024


C. Hardman, Game Programming with Unity and C#, https://doi.org/10.1007/978-1-4842-9720-9_4 23
CHAPTER 4 ■ Parents and Their Children

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

We aren’t limited to a simple parent-child relationship. We can have grandchildren, great-


grandchildren, and so on – as many layers as we want. We could add another cube and make it a child of
the child cube – which would make it a grandchild of the cube we named “Parent.” Then, moving the Parent
cube would move its child, and as a result, it would also move the grandchild.
If you ever want to “unparent” a child (make it no longer have a parent), you can do so in the Hierarchy
window by clicking and dragging the child above or beneath the parent object. Note that while you’re
dragging a GameObject around in the Hierarchy, any other GameObject that you pass your mouse cursor
over will be highlighted in light blue. This means you’ll be assigning the dragged object (the one you’re
“picking up”) as a child to that highlighted object. If there is no object directly under your cursor, you’ll
instead get a blue line with a circle at its left side. This is how you move the object around in the hierarchy:
you can unparent it, place it among the children of another parent, or just move its place among the other
children for organizational purposes.
Pay attention to the left side of the line: that circle will indent further to the right when placing a
GameObject within the children of another. This behavior can be a lot easier to observe when you have more
complicated hierarchies of GameObjects, with multiple levels of children. For our purposes, you can pretty
much just drag an object into the empty space below the others and release to make it have no parent.

World vs. Local Coordinates


Let’s learn the distinction between world coordinates and local coordinates. The position of an object that
has a parent can be depicted in two ways:
• Its world position is its absolute position in the scene.
• Its local position is its position relative to its parent.
When an object has no parent, the Inspector will show us its world position. Once we give it a parent,
the Inspector will instead show us its local position.
A position of (5, 0, 0) in world coordinates is “5 units to the right of the center of the world.”
But in local coordinates, that same position instead means “5 units to the right side of the parent
object.” And that corresponds to the parent’s rotation: notice that I wrote “to the right side of the parent,” not
“to the right.” Rotate the parent, and the local position of the child doesn’t change. Adding 1 point to the X
axis doesn’t move the object 1 unit “to the right” in world space – it moves the object 1 unit to the right of the
parent object.
This is why even a direction can use local coordinates instead of world coordinates. If you’re shooting
out a projectile from the player character in a game where the player is rotating around, such as pointing
their character with their mouse, then you would use the player character’s local forward direction, not the
world forward direction.
A good way to look at it is that the world directions are something like directions on a compass. You
could consider world forward to be north (positive along the Z axis), world backward to be south (negative
along the Z axis), world right to be east (positive along the X axis), and world left to be west (negative along
the X axis). A projectile that’s coming out of a gun, or the flaming hands of a magician, shouldn’t just “go
north,” right? It should go forward along the local direction that the gun or the hands are pointing.
Another complication of local positions is that they’re affected by the scale of the parent. So if the
parent doesn’t have (1, 1, 1) for its scale, then adding 1 unit isn’t actually adding 1 unit, so to speak. The
local position is multiplied by the scale of the parent. For example, if your parent has an X scale of 2, then
adding 1 unit to the X is really adding 2 units in world space.

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.

Figure 4-3. A look at our Skyscraper GameObject

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 healthy social organism, therefore, requires, as a second branch alongside


the body economic, the independent political life of the State. In the
separate body economic, the forces of economic life itself will guide men to
such institutions as best serve the production and interchange of
commodities. In the body politic, the State, institutions will arise, where
dealings between individuals and groups will be settled on lines that satisfy
men’s sense of right. This demand for complete separation of the “rights-
State” from the economic sphere proceeds from a standpoint of reality.
Reality is not the standpoint of those who seek to combine the life of rights
and economics in one. The people engaged in economic life of course
possess the sense of right, but they will only be able to legislate and
administrate in the way “right” requires,—i.e., from the sense of right alone
without any admixture of economic interests,—when they come to consider
questions of right independently, in a “rights” State that takes, quâ State, no
part in economic life. A “rights” State, such as this, has its own legislative
and administrative bodies, both constructed according to those principles
that ensue from the modern sense of right. It will be built up on those
impulses in human consciousness, which go to-day by the name of
“democratic.” The legislative and administrative bodies in the economic
domain will arise out of the forces of economic life. Such transactions as
are necessary between the executive heads of the legislative and
administrative bodies of “rights” and economics respectively, will be
carried on pretty much as between the governments of sovereign states to-
day. This co-ordination of the two systems will make it possible for
developments in the one body to exert the needful influence on the other.
This influence of the two spheres on one another is prevented, when one of
them tries to develope within itself the element that should come to it from
the other.
The economic life, then, is dependent on the one hand on those relations in
“right,” which the State establishes between the persons and groups of
persons engaged in economic work, just as, on the other hand, it is subject
to the conditions of the nature-basis (climate, local features, presence of
mineral wealth, etc.). The bounds are thus marked out on either side for the
proper and possible activities of economic life. Just as nature creates
predetermining conditions, which lie outside the economic sphere, and must
be accepted by the man at work in it as the given premises on which all his
economic work must be based,—so everything in the economic sphere that
establishes a “relation in right” between man and man, must, in a healthy
social organism, be regulated by the “rights-State,” which, like the nature-
basis, goes on alongside and independently of the economic life. In the
present social organism,—as developed in the course of mankind’s historic
evolution up till now,—economic life occupies an unduly large place, and
sets the peculiar stamp that it has acquired from the machine-age and
modern capitalism upon the whole social movement. It has come to include
more than it should include in any healthy society. In the present day,
trafficking to and fro within the economic circuit, where only commodities
should traffic, we find human labour-power, and human rights besides. At
the present day, within the body economic, one can truck not only
commodities for commodities, but commodities for human labour,—and for
human rights as well, and all by the very same economic process. (By
“commodity” I mean everything which through human activity has acquired
the form in which it is finally brought by man to its place of destination for
consumption. Economists may perhaps find this definition objectionable or
inadequate; but it may be serviceable towards an understanding of what
properly belongs to economic life.1)

When anyone acquires a plot of land by purchase, one must regard it as an


exchange of the land for commodities for which the purchase money stands
proxy. The plot of land however does not act as a commodity in economic
life. It holds its position in the body social through the “right” the owner
has to use it. There is an essential difference between this right of use, and
the relation of a producer to the commodity he produces. From the very
nature of the producer’s relation to his product, it cannot possibly enter into
the totally different kind of man-to-man relation created by the fact that
someone has been granted the sole right to use a certain piece of land. Other
men are obliged to live on this land, or the owner sets them to work on it for
their living; and thus he brings them into a State of dependence upon
himself. The fact of mutually exchanging genuine commodities, which one
produces or consumes, does not establish a dependence that affects the
man-to-man relation in the same kind of way.

To an unprejudiced mind it is clear, that a fact of actual life, such as this,


must, in a healthy society, find due expression in its social institutions. So
long as there is simply an interchange of commodities for commodities in
economic life, the value of these commodities is determined independently
of the relations-of-right existing between individuals or groups. Directly
commodities are interchanged for rights, the “rights relation” is itself
affected. It is not a question of the exchange in itself; such an exchange is
the inevitable life-element of the modern social organism, resting as it does
on division of labour. The point is, that through this interchange of rights
and commodities, “right” itself is turned into a commodity, when the source
of “right” lies within the economic life. The only way of preventing this, is
by having two sets of institutions in the body social,—one, whose sole and
only object it is to conduct commodities in the most expedient manner
along its circuit, the other regulating those human rights involved in
commodity-exchange which arise between the individuals engaged in
producing, trading and consuming. Such rights are not distinct in their
nature from any other rights that necessarily exist in all relations between
persons, quite independent of commodity-exchange. If I injure or benefit
my fellow-man by the sale of a commodity, it falls within the same social
category as an injury or benefit due to some action or negligence not
directly expressed in an exchange of commodities.

In the organisation of economic life, that familiarity with business, which


comes from practical experience and specialist training, will give the point
of view needed by the person at the head of affairs. In the “rights”
organisation, the laws and administration will give effect to the general
sense of right in the dealings of persons and groups with one another. The
economic organisation will assist the formation of Associations amongst
people who from their calling, or as consumers, have the same interests or
similar requirements. And this network of Associations, working together,
will build up the whole fabric of industrial economy, The economic
organisation will grow up on an associative basis, and out of the links
between the Associations. The work of the Associations will be purely
economic in character, and be carried on on a basis of “rights” provided by
the rights-organisation. These Associations, being able to make their
economic interests recognised in the representative and administrative
bodies of the economic organisation, will not feel any need to force
themselves into the legislative or executive government of the “rights-
State” (as, for instance, a Landowners’ League, or Manufacturers’ Party, or
a Socialist party representing an industrial programme), in order to effect
there what they have no power to achieve within the limits of the economic
life. If the “rights-State” again takes no part whatever in any branch of
industrial economy, then the institutions it establishes will be such only as
spring from the sense of right amongst its members. Although the persons
who sit on the representative body of the rights-State may, and of course
will, be the same as are taking an active part in economic life, yet, owing to
the division of function, economic life will not be able to exert such an
influence on the “rights life,” that the health of the whole body social is
undermined,—as it can be, when the state itself organises branches of
economic life, with representatives of the economic world as state-
legislators, making laws to suit economic interests.

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.

These remarks will be regarded as “unpractical” by someone who regards


nothing as practicable outside the narrow horizon of his customary life.
Unless he can see things differently, any influence he may retain in any
sphere of life will not tend to heal the disease in the body social, but only to
make it worse. It was people of his way of thinking who helped to bring
about the present state of affairs. There must be a reversal of the movement
which has set in in leading circles, and which has already brought various
departments of economic life (e.g., the postal and railway services, etc.),
within the workings of the State. Its opposite must begin: a movement
towards the elimination of all economic activity from the domain of politics
and State organisation. Thinkers, whose whole will and purpose, as they
believe, is directed to the welfare of society, take this movement towards
State control, started by the hitherto governing circles, and push it to its
logical extreme. They propose to socialise all the materials of economic
life, in so far as they are means of production. A healthy course of
development, however, will give economic life its independence, and will
give the political State a system of “right” through which it can bring its
influence to bear on the body economic,—so that the individual shall not
feel that his function within the body social gives the lie to his sense of
right.

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.

This settlement of labour conditions outside economics, pre-establishes a


basis of value for commodities comparable to the basis already established
by the conditions of nature. The value of one commodity, as measured by
another, is increased by the fact that its raw material is more difficult to
procure; and, similarly, the value of a commodity must be made dependent
on the kind and amount of labour which the “rights” system allows to be
expended on its production.3

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.

It is obvious, that in a social organism conducted in this way the standard of


economic well-being will rise and fall with the amount of labour which the
common sense of right expends upon it. This however must be so in a
healthy society. Only the subordination of the general economic prosperity
to the common sense of right can prevent man from being so used up and
consumed by economic life that his existence no longer seems to him
worthy of his humanity. And it is this sense of an existence unworthy of
human beings that is, in reality, at the bottom of the convulsions in the body
social.

Should the general standard of economic well-being be too greatly lowered


on the “rights” side, there is a way of preventing this, just as there is a way
of improving the nature-basis. One can employ technical means to make a
less productive soil more productive; and, if prosperity declines over much,
the mode and amount of work can be changed. Only, such changes should
not be a direct consequence of processes in the economic life; they must be
the outcome of insight, arrived at on the free ground of “rights,”
independent of economic life.

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?

The peculiar stamp thus acquired by our present-day mental conceptions, in


which the scientific turn of thought predominates over every other, is just
what makes them a mere ideology as they affect the working-class. The
workers have observed, how men’s thoughts acquire a certain character,
arising out of the requirements of state life,—a State life that suits the
interests of the ruling classes. It was a reflection of material interests, and of
the war of interests, that the worker saw when he looked into his thoughts.
Thus there arose in him a sense that all spiritual life whatever was ideology,
a mirrored image of the economic order of affairs. Such a view of things
works havoc with men’s spiritual life. But its blighting effects will cease,
once it becomes possible for them to feel that in the spiritual domain there
reigns a reality that transcends material outward life and bears its own
substance within itself. No such sense of a spiritual reality can, however,
possibly arise, unless the spiritual life is free within the body social to
expand and govern itself according to the impulses inherent in it. Only
those, who have their part in a spiritual life thus freely expanding and freely
governed, can represent it with that strength and vigour which shall ensure
it its due place within the body social. Such an independent position within
human society is indispensable for art, science and a philosophy of life,
with all that goes with these. The freedom of one cannot prosper without the
freedom of all. Although in their substance mathematics and physics may
not be influenced directly by State requirements, yet how they are applied,
the estimate people form of their value, the effect their pursuit has upon the
rest of spiritual life, all these and many other points are determined by State
requirements, whenever some of the branches of spiritual life are under
State control. It is one thing, when the teacher of the lowest grade in the
school follows the line along which the State impells him; it is another,
when he takes his line from a spiritual life that rests on its own independent
footing. Here again, social democracy has done no more than take over a
habit of thought and conventions inherited from the ruling classes. Social
democracy sets before itself as an ideal the incorporation of spiritual life in
a social structure based on a system of industrial economy. But, were its
aim attained, it would be only a further step along the same road that has
led to the present depreciation of spiritual life. It was a right feeling, but a
one-sided one that found expression in the socialist maxim: “Religion is a
man’s private affair”; for, in a healthy society, all spiritual life must in this
sense be a private affair, so far as concerns the State and economic life.
Only, social democracy does not relegate religion to the sphere of private
affairs with any idea of thus establishing its status as spiritual wealth, and
giving it a position within the social order where it may attain to a higher
and more worthy development than under the State’s influence. No; it’s idea
in so doing is, that the resources of the body social should only be used to
cultivate what it needs for its own existence, and that the religious kind of
spiritual wealth does not come under this head. This is not the way in which
one branch of spiritual life can prosper, singled out as an exemption from
public life, whilst all the rest remain in bondage. The religious life of
mankind in this new age will go hand in hand with emancipated spiritual
life in every form, and grow to a force able to bear up the souls of the men
of the new age.
It is a matter for the soul’s own free demand, how the spiritual life is
received into men, no less than how it comes forth from them. Teachers,
artists and others will find, that they have an altogether different influence,
and are able to awaken an understanding amongst the public for what they
are creating, when they themselves have a place in the social order which
has no direct connection with any legislature or government, but only with
such as arise from impulses that lie in the course of the spiritual life itself;
when too they are appealing to people, who are not simply under
compulsion to labour, but for whom an autonomous and independent
political State also ensures the right to leisure,—leisure which awakens the
mind to an appreciation of spiritual values. Here one will very likely be told
by someone, that his own “practical experience,”—of which he has a great
opinion,—convinces him, that if this notion were carried out,—if the State
made definite provision for leisure hours, and if school attendance were left
to people’s own sense, it would simply mean that people would spend all
their leisure in the public house and relapse into a state of brute ignorance.
Well, let such “pessimists” wait and see what will happen when the world is
no longer under their influence. Their line of action is all too often
prescribed by a subtle feeling, a secret voice, that whispers in their ear, how
they themselves like to spend their leisure hours, and the steps that were
necessary to ensure themselves having a decent education. Of the free
spiritual life, of its power to fire and kindle, when left to itself within the
body social,—of this such persons naturally take no account. They know
the spiritual life in bondage only, and so it has no power to kindle any spark
within themselves.

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.

At the end of the eighteenth century, under different circumstances from


those in which we are living to-day, there went up a cry from the hidden
depths of human nature for a re-formation of human social relations.
Through all the scheme of the new order ran like a motto the three words,
Fraternity, Equality, Liberty. Of course, no one with an unprejudiced mind
and normal human feeling for the realities of human evolution can fail to
sympathise with all that these three words imply. But still, in the course of
the nineteenth century there were keen thinkers who were at pains to point
out the impossibility of realising the three ideas of brotherhood, equality
and freedom in any homogeneous and uniform order of society. It seemed
to them clear, that these three impulses must contradict one another in social
life, if carried actually into practice. It was, for instance, very cleverly
demonstrated, that if the impulse towards e q u a l i t y were r e a l i s e d
there would be no possible room for that freedom which is so inherent in
every human being. And whilst one cannot but agree with those who see the
contradiction between them, yet at the same time, one’s human sympathies
must go out to all and each of these three ideals in itself!

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.

Capital and Capitalism, as talked of to-day, indicates something in which


the working-class portion of mankind look for the cause of their grievances.
But to come to any profitable conclusion as to the part played by capital
within the social processes, whether for good or ill, one must first be
perfectly clear as to the way in which capital is produced and consumed,
through the agency of men’s individual abilities, of the “rights” system, and
of the forces of economic life. Human labour one talks of, as the thing that,
together with capital and the nature-basis of industry, goes to the creation of
economic values, and through which the worker becomes conscious of his
social position. To arrive however at any conclusion, as to the proper way
of working human labour into the whole social organism without injuring
the worker’s sense of self-respect as a human being, one needs to keep
clearly in sight the relation that human labour bears, on the one hand to
individual ability and its development, and on the other to the common
sense of right, the “rights-consciousness.”

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 obvious, that the social activities, which a man is enabled to exercise


by means of capital, fall within that domain of the body social which takes
its laws and administration from the spiritual life. If the political State
interferes to influence these personal activities, then it is unavoidable that
its influence should involve a disregard of individual abilities. For the
political State is necessarily based on what is similar and equal in all men’s
claims in life; and it is its business to translate this equality into practice.
Within its own domain, the State must ensure every man having a fair
chance to make his personal opinion tell. For the work the State has to do,
the question of understanding or not understanding individualities does not
come in; and therefore whatever the State does towards realising its own
principles ought not to have any influence upon the exercise of men’s
individual abilities. Nor should it be possible for the prospect of economic
advantage to determine the exercise of individual ability where capital is
needed. Many persons in weighing the pros and cons of capitalism lay great
stress upon this economic advantage. In their opinion, it is only through the
incentive which this gives to individual ability that individual ability can be
induced to exert itself; and they refer, as “practical men” to the
“imperfections of human nature,” with which they claim to be well
acquainted. No doubt, in that social order, under which the present state of
things matured, the prospect of economic advantage has come to play a
very important part, and is in no small measure the very cause of that state
of things, of which we are now feeling the effects, and which calls for the
development of some other, different incentive to the exercise of individual
ability. This incentive must lie in the “social sense,” that will spring from a
healthy spiritual life. Strong in the freedom of the spiritual life, a man’s
education and schooling will send him forth equipped with impulses, that
will lead him, thanks to this social sense, to realise the bent of his personal
abilities.

There is not necessarily anything high-flown or visionary about such a


belief. No doubt high-flown illusions have wrought immeasureable harm in
social endeavour, as in other fields. But all that has been said before is
enough to shew, that the view here urged is not based on any fanciful notion
that “the spirit” will work wonders, provided the “spiritually-minded” only
talk enough about it. It is the outcome of observation, of watching how
people actually work, when they work together freely in the spiritual field.
This work in common, takes, of its own nature, a social character, provided
it can develope in real freedom.

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.

E a r n i n g s on everything done through capital and individual ability must


depend in a healthy social order, like all other spiritual work, on the free
initiative of the doer and on the free appreciation of those who wish the
work done. The estimate of what these earnings should be, must, in this
field, be in accordance with a man’s own free view—on what he is willing
to regard as a suitable return on his work, taking into consideration the
preliminary training he requires for it, the incidental expenses to which he is
put, etc., etc. Whether he finds his claims gratified or not, will depend on
the appreciation his services meet with.

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.

The reason why people are so ill-disposed to-day to form an unbiassed


opinion as to the position spiritual life occupies in the social order, is that
they are accustomed to think of what is spiritual as being at the opposite
end from all that is material and practical. Not a few will find something
rather absurd in the view here put forward, that the employment of capital
in economic life must be regarded as the way in which one side of the
spiritual life manifests itself. It is conceivable, that in characterising what is
here said as absurd, members of the late ruling classes may even find
themselves in agreement with socialist thinkers. If one would see all that
this supposed absurdity means for the health of the body social, one must
examine certain currents of thought in the present day,—currents of
thought, which spring from impulses in the soul, that are quite honest after
their fashion, but which nevertheless, wherever they find entrance, check
the development of any really social way of thinking.

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.

Free use of the capital-basis through individual ability:—this must be an


established possibility. The ownership right involved in it must be shiftable,
directly this right begins to turn to a means of unrightfully acquiring power.
There is one institution, introduced in our times, which partially meets this
social requirement, though only for what one may call “spiritual property.”
“Spiritual property” when its author is dead, passes after a while into the
ownership of the community for free use. Here we have an underlying
conception, that is in accordance with the actual nature of life in a human
society. Closely as the production of a purely spiritual possession is bound
up with the private endowment of the individual, yet this possession is, at
the same time, a result of the common social life, and must pass at the right
moment into the common life. But it is just the same with other property.
By aid of his property the individual person produces for the service of the
community; but this is only possible in co-operation with the community.
And accordingly the right to the use of a piece of property cannot be
exercised apart from the interests of the community. The problem is not,
how to abolish ownership of the capital-basis? but, how can ownership be
best turned to the service of the community?

The way to do so, is to be found in the threefold order of society. The


people combined in the threefold order act as a collective community
through the “rights-State.” The exercise of individual abilities comes under
the spiritual organisation.

Everything in the body social indicates the necessity of introducing this


threefold organic arrangement, when regarded with a sense of actualities,
and not from a view entirely dominated by subjective opinions, theories,
predilections, and so forth;—and this question of the relation of individual
abilities to the capital-basis of economic life and its ownership, is a special
case in point. The “rights-State” will not interfere with the formation and
control of private property in capital, so long as the connection of the
capital-basis with personal ability remains such, that this private control
implies a service to the total community. Moreover, it will remain a “rights-
State” in respect to its dealings with private property. It will never itself
take over the ownership of private property. It will only ensure that the right
of use is transferred at the right moment to a person or group of persons,
who, again, through individual conditions, are capable of establishing a
purely personal relation to this ownership. This will benefit the body social
in two different aspects. The democratic foundation of the “rights-State,”
being concerned with the everything that touches all men equally, will
enable a sharp watch to be kept, that property rights do not in course of
time become property wrongs. And again,—(since the State does not itself
administer property, but ensures its transference to individual ability),—
men’s individual abilities will develope their fructifying power for the
whole body of the community. Under an organisation of this sort, property
rights, or their exercise, can safely be left attached to a personality, for so
long as seems opportune. One can conceive the representatives in the
“rights-State” laying down quite different regulations at different times as to
the way in which property is to be transferred from one person or group to
another. At the present day, when private property has come to be regarded
altogether with great distrust, the proposal is, to convert private property
wholesale into communal property. If people proceed far enough along this
road, they will find out, that they are strangling the life of the community;
and, taught by experience, they will then pursue a different path. But it
would undoubtedly be better now, at once, to take measures that would
secure social health on the lines here indicated.

So long as an individual alone, or in combination with a group, continues to


carry on that productive activity which first procured him a capital-basis to
work on, so long he shall retain the right to use accumulations of capital
arising as business gains on the primary capital where the gains are applied
to the productive extension of the business. Directly this particular
personality ceases to control the work of production, the accumulation of
capital shall pass on to another person, or group, to carry on the same kind
of business, or some other branch of productive industry useful to the whole
community. Capital also, that accrues from a productive industry but is not
used for its extension, must from the beginning go the same way. Nothing
shall count as the personal property of the individual directing the business,
except what he receives in accordance with the claim he made when he first
took over the business—claims, which he felt able to make on the ground of
his personal abilities, and which appear justified by the fact, that he was
able to impress people with his abilities sufficiently for them to trust him
with capital. If through his personal exertions the capital has been
increased, then a portion of this increment will pass into his private
ownership,—the addition so made to his original earnings representing a
percentage on the addition to the capital. Where the original controller of an
industry is unable, or unwilling, to continue in charge, the capital used to
start it will either pass over to the new controller with all incumbent
obligations, or else will revert to the original owners, according as these
latter may decide.
In such an arrangement, one is dealing with transfers of a right. The legal
regulation of the terms on which such transfers shall take place, is a matter
for the “rights-State.” It will be for the “rights-State” also to see that these
transfers are carried out and to conduct the process. It is conceivable that, in
detail, the regulations laid down for any such transfer of a right will take
very various forms, according as the common sense of right (the “rights-
consciousness”) varies in its view of what is right. No mode of conception,
which, like the present one, aims at being true to life, will ever attempt to
do more than indicate the general direction that such regulation should take.
If one keeps to this direction and uses one’s understanding, one will always,
in any concrete instance discover what is the appropriate thing to do. One
must judge always from the special circumstances and according to the
spirit of the thing, what the right course is in actual practice. The more true
to life any mode of thought is, the less it will attempt to lay down hard-and-
fast rules for details, from preconceived notions of what is requisite. On the
other hand, the very spirit of such a form of thought will lead necessarily
and decisively to one result or another. For instance, it results
unquestionably from such a mode of thought, that the “rights-State” must
never use its control of rights-transfers to get any capital into its own hands.
Its only business will be to see, that the transfer is made to a person, or
group, whose individual abilities seem to warrant it. This at once
presupposes also, as a general principle, that anyone, who is proposing to
effect a transfer of capital under the circumstances described, will be at
liberty to select his successor in the use of it. He will be free to select a
person or group of people, or else to transfer the right of use to a corporate
body belonging to the spiritual organisation. For anyone, who has rendered
practical services to society through his management of capital is a person
likely to judge from native ability and with social sense, what should be
done with the capital afterwards. And it will be more advantageous to the
community to go upon what he decides, than to discard his judgment, and
leave the decision to persons who have no direct connection with the matter.

Some settlement of this kind will be required in the case of capital


accumulations over a certain amount, which have been acquired by persons,
or groups, through the means of production (including land),—except
where these accumulations become private property by the terms originally
agreed upon for the exercise of individual ability.

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.

In a society ordered on these lines, due regard is paid both to private


initiative on the part of the individual and at the same time to the social
interests of the general community. Indeed the latter receive their full
satisfaction through private initiative being set free to serve them. Whoever
has to entrust his labour to the direction of another person, can at least
know, under such an order of things, that their joint work will bear fruit to
the best advantage of the community, and therefore of the worker himself.

The social order,—as here conceived,—will establish a proportionate


relation, satisfactory to healthy human sense, between the prices of
manufactured products and the two joint factors of their production,—
namely human labour-power and these rights of use over capital (embodied
in the means of production) which are subject to the common sense of right.
No doubt all sorts of imperfections may be found in this. Imperfections do
not matter. For a mode of thought that is true to life, what is of importance
is not to lay down a perfect and complete programme for all time, but to
point out the direction for practical work. The special instances, discussed
here, are simply intended as illustrations to map out the direction more
clearly. Any particular illustration may be improved upon; and this will be
all to the good, provided the right direction is observed.

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.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmasss.com

You might also like