Game Development Learning Log #1
So, this is where it all starts.
I’ve been putting off learning game development for years (since I was 12) due to a fear of failure and a fear of disappointing my dead father who would program games in both BASIC and machine code. Now I will make him proud and use this game development learning log to keep track of my progress.
I have recently started learning Unity Engine, C# and some basic game development concepts.
I need to make sure that I keep up with and maintain my knowledge, so I’ve started this game development learning log to keep track of my progress and remind me where I started.
So far I’ve covered:
- Variables
- A name that data can be assigned against data
- i.e. pantsSize = 147;
- C# uses ; to end lines
- We usually define a data type for variables, in this case an int for integer value
//Narrator: he was a large person.
int pantsSize = 147;
string pantsName = “Unders”;
bool isWearingPants = false;
float averagePantsWornPerWeek = 3.5f; - You can also set these without defining the value first:
int pantsSize;
- We can then modify that further such as:
pantsSize = pantsSize +6;
//Narrator: Covid has not been good to me
- Using camelCaps (rather than PascalCase or Under_Score) for variables is standard practice
- Variable names are case-sensitive:
thisThing and thisThiNg are two separate variables - Variable names should not be a C# keyword
don’t do: string string = string; - Variable names cannot start with a number
- Variable names cannot use # or other special characters
- Variables can be implicitly typed (ie you may not know what they are until they are initialized):
var message = thisThing.customProperty;
or
var message = “this is so large” - You can find the list of data types for C# here
- Methods
- A set of repeatable instructions that can be run
void getLargerPants ()
{
//Actions for getting larger pants in here
}
- Can have no inputs or multiple inputs
void getLargerPants(string shopName, int priceOfItem)
{
//Actions for getting larger pants in here
} - Can have no output or return a type
- if returning a type then the whole method is turned to a type:
int LargenessAttained (int pantsSizePreCovid, int pantsSizePostCovid)
{
LargenessAttained = pantsSizePostCovid – pantsSizePreCovid;
return LargeNessAttained;
} - we use void to define a function with no returned output
- if returning a type then the whole method is turned to a type:
- We can then call these methods from our script and include the inputs required:
LargenessAttained(22, 37)
- A set of repeatable instructions that can be run
- Comments
- // for single line comments
- /* for block comments
- */ to close
- The saying goes “When in doubt comment it out”
- Make comments for ‘future you’ to understand what is going on at a glance rather than having to decipher code, don’t make them just thinking that someone else will be reading them
- Comments should be clear, concise and descriptive
- C# Classes
- Way to group variables and method together into a larger container
- These can be used to simplify and organise code
- We can use scripts in 3 ways roughly
Scripts as behaviours, scripts as static objects (can’t be added to objects as static prevents), - We can use inheritance to extend existing classes into sub-classes ie Clothing can be extended to become Pants
- Unity’s Monobehaviour class has certain common functionality methods that allow us to easily define other classes
- ie the Start() method runs at the beginning of every game
and the Update() method runs every frame
- ie the Start() method runs at the beginning of every game
- Class Enemy can extend Monobehaviour to gain the functionality of monobehaviour by default and extend the functionality of that further:
Class Enemy: Monobehaviour ()
{
bool isWearingPants = false;
} - If we have multiple copies of that Enemy class assigned to objects, they will act as an instance of that object and contain their own individual variables and states.
- We can set a variable within a class to act across all classes of that type by defining it as static
static int totalPantslessEnemies = 0;- If we increment that variable by 1 in our Start()
Start()
{
totalPantslessEnemies = totalPantslessEnemies +1;
} - Spawn 5 pants-averse enemies
- The value of that variable, totalPantslessEnemies, will be 5
- Whereas a normal instance value for that particular instance would show as 1, as only that instance increased by 1, unlike the class-level static variable we have created.
- If we increment that variable by 1 in our Start()
- If we add public in front of that variable, we make that value accessible to other classes and the property will show within the properties window of the script when applied to an object
- We can then, from another object, check Enemy.totalPantslessEnemies
- We cant’ access instance variables this way as they would require narrowing down which instance we are checking for
- Unity Interface
Hierarchy
– Shows all objects within the scene (can have multiple scenes in a project)

Scene
– the view into your overall scene of objects and their orientation/placement/state within that
– scroll to zoom in and out
– can select, move, rotate, scale etc – shortcut keys for these are q/w/e/r/t
– the directional axis widget in top right corner can be used to switch to different axis views by clicking the axis, and can switch between isometric and perspective modes but clicking the cube in the centre of that widget.


Game
– see the actual end-output of our scene and scripts, viewed from the perspective of the camera object


Inspector
– provides information on any selected object
– this is where we apply settings, scripts and change properties of objects

Project
– contains all imported and available assets for project

Console
– A tool for debugging
– we can send variables or values or messages etc to this using Console.Log
– errors in scripts and during runtime will show up within this window

That’s it for today, you can view my future updates and game development learning log posts and other game development articles by clicking here
I’m hoping to do at least one game development learning log per month, ideally more but I don’t want to put too much strain on myself considering my other obligations.