If you’ve worked with Lists in Python before, you’ll quickly realise that they work differently from primitives like integers and strings. Consider the following:
a = "hello"
b = a
a = "world"
Notice that changing the value of
a does not change the value of
b. This is called passing by value. In Python, Lists do not behave this way:
a = [2, 3, 4, 5]
b = a
In the above example, notice that changing the value of List
a also changes the value of List
b. This is because both
b are referring to the same List, and this is called passing by reference.
As part of a school assignment in the past year, my team and I created Apoca Force, a tower defense game where WAIFUs (World Apocalypse Intercepting Frontline Units) are deployed onto a battlefield to combat an undead horde. To provide some variation (and eye candy) in gameplay, the game provides a variety of different WAIFUs for players to deploy.
To display the different stats WAIFUs have, we decided to include a radar graph on our build interface to illustrate the stats of each type of WAIFU. In this article, I will talk about the technicalities involved in making that happen.
I have previously written an article about how we rendered Unity’s NavMesh to show our WAIFUs’ walkable areas. Check it out!
A common problem I see in novice Unity game programmers is that they often create too much unnecessary, duplicate code. Take, for example, the programmer who creates a simple 2D platformer with a player character and a generic enemy character to be duplicated across the level. What often happens is that two separate scripts will be created — one for the player character, and one for a generic enemy character. Each individual script will define its own behaviours for things such as movement, jumping, dealing damage and receiving damage, and most of the code between these two scripts is similar because the character types have so much in common.