Dev Log #5 Cutting halves in half

Dev Log #5 Cutting halves in half

When starting out with a game in a powerful engine like Unity it seems like everything is possible and that you can make a game in a finger snap. While everything is possible and you can make something playable in a relatively short time span, making a complete game usually takes a fair share of time, especially if you are a newbie to game design, engine itself and programming.

As far as i can tell, illusions of grandeur are quite common when you begin developing a game (turns out i was not immune to it too). Enthusiasm doesn’t seem to whiff away quite easily as it is fueled by actual things getting done, but after a while you get to realize it will take too much time to make it like you want it to be, or you simply don’t know of a way that is fast and simple enough. If you want to complete the game, you will need to strip it of layers and keep it simple. It hurts and feels like taking away the originality and personality from it. Not only will you have to cut it in half, but you will probably need to cut that half in half too, reducing it to meager ¼ of the game you meant to make.

One of the things i had to cut again and again was the weapon system i was quite proud of. You can read about it here and here’s the short version:

30+ weapons in game;
5 levels of each weapon;
3 weapon types (bullet, energy, missile, each having a corresponding multiplier against normal, armored and shielded enemies);
Player can hold two weapons at the same time, but fire only one;
You can’t have two same weapons of different levels equipped;
You can’t have two weapons of same type equipped;

You have Bullet Weapon X Level 1 equipped as active weapon and Energy Weapon X Level 1 equipped as inactive. After blasting the enemy transport you come across Missile Weapon X Level 1 and pick it up. Since you don’t have it equipped in any of slots, it will replace the active weapon and eject Bullet Weapon X Level 1.

If you wanted to replace the Energy Weapon X Level 1, you could simply switch weapons to make Energy Weapon X Level 1 active and replace it. This would be a common occurence for adapting to the enemy types because of their vulnerability or resistance to certain type of damage.

I could make things simpler in design and coding by simply omitting the part where the replaced weapon is ejected since there’s a small chance of picking it up by accident since it involves pressing a key while you hover over the weapon. However, two player mode requires that feature for the weapons to be interchangeable between players and that is a great way to improve cooperation, gameplay and combined firepower.

Reality check!

Due to design limitations (limitations as in 150 weapon variants) i had to make a hard choice that can affect the future gameplay on upgrading the equipped weapon and few solutions came to my mind.

1. You can only upgrade the weapon if you pick up the exact weapon

That way, either equipped or not, the weapon in players posession is upgraded to the next level without any ejection which only happens when you are picking up a weapon you don’t have equipped. While challenging with high long-term impact on decision-making, you only have 6% chance of getting the same weapon from the transport which is slim to none. Needles to say, a bad option.

2. Equipped weapon level transfers to pickups

Whenever you equip a weapon that is not equipped it is always at level 1, but when you upgrade any of the weapons on ship to level 2, the weapon you replace the level 2 weapon will also be level 2. Basically, it would be a kind of cheating, since by dropping and re-equipping active and inactive weapons, you could get all equipped weapons to a higher level.

3. Weapons upgradeable only by picking up the same weapon

To make it more viable, one should increase the chance of spawning a weapon you already have.

The maths on this one are simple, though a bit hard to code. You have 25% of transport spawning active weapon, 25% of spawning inactive weapon and 50% chance of spawning a new weapon. This comes with a different kind of trade-of. Though 25% is a lot ot may happen that you rarely run into a weapon you want to upgrade. On the other hand, you may always run into a weapon you already maxed out. This discourages experimentation since you will always want to hold on to your maxed out weapons, no matter how good or bad they are. There are no bad weapons per se, but holding on to weapons of the same type greatly decreases success.

4. Weapon upgrade pickups

Though not originally meant to be implemented, this could pose a good solution combined with approach 1 or 2. It is simply a kind of a joker card which levels up your active weapon without worrying if it’s the same one. You pick it up, the active weapon gets upgraded and you just keep on blasting.

The basic idea was for the player to drop the currently equipped weapon when he picks up the new one, so if a mistake is made (though hardly possible, since only hovering over it won’t do – you have to press a pickup key too) player can simply pickup the ejected weapon again.

Resolution

I don’t know about you, but i got a headache just by reading this. You see how easy it is for things to get out of hand for every single layer of stuff you intend to add? Amount of work increases exponentially for every feature added. Not only did it get overly complicated, but it got to the point where it would depend on chances of picking up weapons that would be extremely hard to tweak properly. And all that doesn’t guarantee that you won’t end up in situation to have no proper weapon to amswer the challenge on the screen, which is unacceptable.

On top of that, i wanted to implement weapon overheating mechanics, but to be honest, i haven’t played any game except Jets ‘n’ Guns that has it, and that game has a completely different concept.

In the end, the whole system got stripped down to bare essentials, and an easy to understand concept:

You start with all 3 weapon types on ship (basic weapons);
No switching – you have a button for firing every weapon (with a small delay between firing a different weapon, something like auto-switching);
Automatic picking up, you don’t need to press a key while hovering over a weapon to pick it up;
When you pick up a weapon, it replaces the one with the corresponding type on the ship and the old weapon does not get ejected;
No weapon levels, which brings number of weapons to a manageable number (maybe i’ll put SOME levels in the future, but i doubt it);
No overheat mechanics, it would add another layer of tweaking which would require enormous amount of time of testing;

Much better and easier to grasp.

After a while you don’t look at the striping like something that made your game bland and simple, but as a salvation from meaningless work that would probably be too complicated for you and not turn out well. Obviously, perfection is not a thing to strive for, especially if you are a solo developer. Much bigger games suffered for trying to achieve it. So, keep it simple, and cut, then cut again.

Ode to Nested Prefabs from a noob indie dev

Ode to Nested Prefabs from a noob indie dev

His Majesty, the Prefab

I must admit that i’ve been a bit what you could call ‘lazy’ for the past few months.  Why is lazy hyphenated? Well, because i’m not really lazy, i just tried to finish a game from 0 knowledge of Unity in under two years, which is not an easy task. I spent a lot of sleepless nights working, had a few burnouts, but one thing ultimately slowed down my progress to almost halt.

When i finished most of the mechanics for the game and got to the most important part – making content – i simply couldn’t find any more willpower because of the tedious process involved in making hundreds of enemy waves. I believe someone with better coding skills could make a level editor and finish it much quicker, but with my knowledge, i had to do everything by hand and i kind of lost the motivation. Let’s delve a bit deeper into the problem.

One of the things i really love about Unity is use of Prefabs. As someone who is not a programmer by trade, it was easy for me to relate to something drag and droppable, an object with belonging properties that is simple to instantiate and easy to manipulate without much hassle. Two years ago, one of my first questions on Unity Forums was about something that i didn’t even know what is called back then – Nested Prefabs. I couldn’t understand why instantiated objects could have child objects that have child objects who also have child objects can exist in the scene, but not as a Prefab. That pretty much broke my building blocks concept of making a game.

Harsh red line reality check

As you can see, i imagined the waves of enemies to be compiled of squadrons (as well as waypoint and single enemies, about which i wrote in my previous logs) which would be a Prefab object with lots of children objects (singular ships and their engine jets, weapon, tags for missile homing and so on). Unfortunately, Unity supports only one level of vertical nesting in the project, so while an object can have literally hundreds of children, non of them can have their own. Since i read that the Nested Prefabs are something that was planned more than five years ago and not yet in the making i tried a few assets that simulate Nested Prefabs but to no avail. You’ve probably seen the horrible reviews on the Asset Store, most of them are abandoned, buggy, slow or complicated. Since i found no decent asset that will enable me to work the way i imagined, i resorted to the usual workflow of instantiating a Prefab and populating it with components that i needed.

The usual get this/set this workflow

It wasn’t too hard for single enemies, all i needed to do was instantiate appropriate objects on designated locations and that’s it. I learned a lot of things in the process, getting and setting the properties of many available components and their variables, the importance of pooling and the way it works, managing performance and so on. I must admit i had more than a handful of situations where i didn’t know how to overcome some of the challenges, but i’m grateful for them since they were an opportunity to learn something new through problem solving. When most of the stuff that make the core of the games look and feel were finished, the harder part of making a game in the true sense of words came. I won’t repeat myself too much, you can read more about my process of making waves in this and this log. In short, instead of dragging and dropping positions where i want the ships to spawn, assign the wanted behavior to each one depending on the wave structure and simply save all that as a prefab i need to:

  • Have specific spawner types. That means single enemy, waypoint enemy and squadron enemy spawner with their locations.
  • Make a specialized movement FSM’s for almost every enemy type that will dictate movement direction and scale of ships and ships’ children. For example, engine jet needs to be a separate object so it doesn’t flash with the ship upon bullet contact but it must be properly rotated and scaled depending on the spawning position and spawner parent of the parent (yeah, even i lost it while reading).
  • Assign more elements to pool which slows down the compilation time and time required to start the game. Instead of pooling one ship with all the needed components i need to pool the ship prefab, jet prefab, weapon prefaband in some cases multiple weapon prefabs so the pool size for ships is actually at least three times the size in terms of object number. I’m fairly certain that it’s better to have fewer objects to instantiate regardless of their complexity (number of components attached).
  • Manually set the spawning position of each ship in the wave. This is the worst part, it got me completely devastated. I need spawners for assigning some general behaviors and general screen position, but all the fine arrangement of ships in the wave must be done by hand. Not completely, but i need to put the ships in the scene so i can get their coordinates, then copy them into the spawning FSM of the squadron. Sure, i need to position the ships with nested prefabs too, but only once and that’s it. Doesn’t sound like much of a fuss, but imagine having hundreds of waves to make with some of them having double digit number of enemies that need to be repositioned upon spawning.
Set Position, Set Position, Set Position

I’m sure some people don’t even use prefabs but create instances and populate them on runtime and i presume some more C#-savvy people will find nothing unusual in this and develop their own systems for handling the situation, especially big teams. But i’m neither of those and, for the time being, i really need nested prefabs to finish what i’ve started. Prefabs are great game building blocks that further upgrade great tool that Unity already is and we should be really glad they are taking into account the needs of small or one man teams. I’m anxious to see further improvements that the new prefab system will bring to the table in the future versions.

 

 

Scoring System Design

Scoring System Design

One of the most important aspects in a shoot ’em up is certainly score. Being somewhat a niche of a genre, it has a clear competitive edge among its players. It certainly lacks fulfillment in terms of engaging story, but the adrenaline rush in combination with the goal of attaining higher and higher scores or even being on the top of the leaderboard is something really hard to beat and is specific to the genre.

With that in mind, a good shmup scoring system has to be easy to understand and engaging at the same time. While it sounds simple, it can be quite hard to achieve a good “funness” factor while keeping it engaging and skill related.

For Rick Henderson and the Artifact of Gods, i dissected a ton of old and new shoot ’em ups in the search for the perfect scoring system i like. One of my all time favorites is certainly Galaga Deluxe (or Warblade for PC folks) for Amiga 500 from late Mr. Edgar M. Vigdal. Besides coins used for shop purchases (which this game won’t be using until singeplayer mode is done), in Galaga you can collect gems too. Those little cuties come in different shapes and colors and each one yields a different amount of points. While not groundbreaking, it adds another layer of depth to the game besides dodging as some gems are really worth running for through a rain of bullets. Naturally, tougher enemies have higher percentage of dropping rarer gems that yield higher score addition.

Gems

Another form of bonuses that can be picked up are medals. Far from my knowledge, medaling is prominent in shoot ’em ups. The concept is easy: you pick up differently colored medals, when you have the whole set, you get awarded a rank at the end of the level and the medal collection is reseted when you start the next level. You guessed it, ranks are just another name for total bonus multiplier at the end of the game.

Ranks

There is a total of 9 ranks you can attain (the first being the multiplier of 1, which is your default rank):

Recruit
Private
Corporal
Sergeant
Lieutenant
Captain
Major
Colonel
Marshal
Commander

Complete randomness in spawning those can be infuriating for players with higher skill cap, but i find it refreshing to have a bit of a variety and a possibility for the medals already collected to appear again. Below you can find a weight distribution chart for the medals. When none are collected, the chance for any to spawn is equal. However, as the number of collected medals increases, the chance for already collected medals to appear diminish by 1/5 (or 20% if you like it that way). I haven’t done the exact maths, but the chance for already collected medals to appear is not that large. Of course, for collecting already collected medals, you get a nice, juicy score bonus, so they are worth catching too!

Rank Chance Weight Distribution

Multi kill bonuses! We all played Unreal Tournament 2004 back in the day. It had a nice feature of multikills which i use in my game in a bit different form. For those who haven’t played it, you get multikill for killing two enemies in a row without dying. As your kill count progresses (again, without dying) you get megakill, ultra kill and so on. In Rick Henderson and the Artifact of Gods it functions based on time between two kills. When you kill an enemy, an invisible timer starts counting down. If you manage to kill another enemy until the counter hits 0, you get double kill and the timer resets. If you manage to get another one until timer counts down, you get a multi kill, all the way to monster kill. Of course, every additional kill is awared with more and more points. This is usually possible with area of effect weapons (explosive ones) and weapons like Railgun, which can go through multiple enemies, encouraging player to invest more skill in the game.

Grazing bonus is usually omnipresent in bullet hells, a hardcore subgenre of shmups. It encourages the player to “graze” bullets, ie. pass very close to them without getting hit.

Design itself was a bit harder to implement since it involves tracking multiple bullets at a time getting into the graze range and checking whether they hit the player or not. 

While not neccessary for the gameplay since i don’t want it to be bullet hell, it’s one of those things setting apart rookies from hardcore players that want to get the most out the game.

And finally, the good old bonus multiplier which adds up with every destroyed enemy, gets lowered when you get hit, and reset at every waves end. It goes well in combination with grazing bonus, making you get closer to the bullets but not get hit. It also serves as a kind of damage control system. Since i gave up on the idea of having a 0-100 healh bar and chose a 10 life bar instead, hits from tougher enemies take more of your bonus multiplier down.

I believe the score mechanics are very easy to understand and will add up much to the investment of the player and the adrenaline pumping of the true genre players.

Playing with lights

Playing with lights

Every now and then you have to change your routine to avoid boredom and relax. So, i started playing around with light to add some depths. Looking good so far!

ezgif.com-video-to-gif

Laser Beam Testing

Spawning System Overhaul and overcoming the obstacle of enemy pattern making

Spawning System Overhaul and overcoming the obstacle of enemy pattern making

The Grid

Wow, it’s been a while, but things are moving forward slowly but surely!

I’ve been busy with lots of coding and programming enemies and i encountered some difficulties in proper positioning. On the image below you can find how the spawn points looked (5 spheres on each side) and how they look now (the red X signs)

Spawning Grid
Obviously, 12 times more spawning points offer much more flexibility

Obviously, it offers much more in terms of positioning. More than a year ago, when i first started working on a spawn system i wasn’t apt enough to make it the way i wanted to (grid system) so i had to be satisfied with only a few spawn points and additional repositioning upon instantiating. Needless to say, it adds much more work to simple spawning and positioning of those enemies.

By using this handy tool from the asset store (https://www.assetstore.unity3d.com/en/#!/content/20502) i created a grid made out of objects completely automatic. A fine tool indeed. After that, i simply added those to the hash table and now i can simply reference the object whose position i want the enemy to use as spawn point and voila. Besides using it to spawn enemies already in a pattern, i can use them to actually create random patterns on runtime by referencing a different object from the hash table upon predefined parameters to avoid completely random clutter. Not only that, a finer grid enables me to avoid spawning the enemies too close to each other or overlap. Since i’m using Core Game Kit for spawning, i’m waiting for the developers to implement the feature based on sphere raycasting, i.e. if there’s an object of certain tag or layer (enemy) in a defined range, the system won’t spawn any more to avoid the overlapping. It will work great with the system i made and described few devlogs earlies which is based on enemy pool values and enemy quantities.

Also, Easy Save 3 Beta will soon get a full release (i hope VERY SOON) which will enable IMPORTING variables from a .csv file. It will be of an immense help for tweaking the gameplay.

Enemy Pattern Making (Squadrons)

I must admit, though i am passionate about making a game, some things are quite tedious. I’m having problems with making enemy squadrons, and the way i make them is so boring and uninspiring it really halts my progress.

Before i was well into Unity engine limitations on nested prefabs (only one child per object, i.e. child cannot have it’s own child as a prefab, only when instantiated on runtime due to way serialization works) i thought it was going to be a breeze, i just drag and drop enemies in a formation, put them under a parent prefab and voila! Except it doesn’t work like that. All of my enemy prefabs typically have two children, Gunpoint and Thruster. Gunpoint hold the shooting logic and muzzle flash animation, while Thruster has the, well, thruster animation. It is on a separate object to avoid being colored with the rest of the enemy ship when it changes color on hit by a player weapon.

So i guess i’ll keep my work and make an empty squadron prefab which will spawn and then spawn the enemies in a desired pattern coded into it. That’s all nice and dandy until you actually start working that way. No more cosy drag and drop, just selecting what to spawn, input coordinates and hit play too see what you’ve done. If something’s not positioned correctly (it usually isn’t), reposition the enemy, copy the coordinates, stop, and paste them. Repeat 10 times for 10 enemy objects in a squadron, and i should have hundreds of them! Horrible!

Prefab and Runtime comparison
Prefab with multiple children with position setting on runtime

So i decided to change my ways. I need to make a reverse approach. Instead of creating an enemy prefab with all the children attached, i’ll attach the Gunpoint and Thruster on instantiation, which is only a two step process compared to setting the position of multiple enemies inside the squadron. This way, i have a clean enemy prefabs without children which i can joyfully drag and drop into positions i want and simply save them under a prefab which will be used for spawning.

Prefab and Runtime Setting 2
Prefab with multiple children instantiating on runtime

Though it is a bit more work initially, it provides an immense saving of time later and makes it more visual, fun and intuitive to work with.

Backgrounds work

Backgrounds work

I bought this little fella (http://www.wacom.com/en-br/products/pen-tablets/one-wacom-m) a while ago but i never found time to play around with it. This weekend was very hot so i was mostly home and i’ve drawn a background for the game, hope you dig it. Took me a few hours.

Background

7 ways to avoid burnout

7 ways to avoid burnout

To Do List

Burn-out, in shortest possible, is a state of physical and mental exhaustion. Is is caused by too much work and stress, and not enough rest and sleep. It can lead to severe health problems, with the smallest one being clinical depression. Apparently, it is very common in game development professions.

I started working on Rick Henderson And The Artifact Of Gods a year and a half ago. First, everything was going fine. Fueled by passion and motivation, i stayed late many nights and used weekends to recover from that maniacal tempo. Then the weekends weren’t enough. I started barely waking up and functioning very lousy. Eating too much to get energy, drinking too much coffee. Quality of work started to fall, and it took me more and more time to finish stuff. My concentration was going down. I got frustrated when i simply couldn’t stay up anymore because i lacked energy. When i did stay up, it was a torture of mind and body with work quality falling down even more. Depression started to creep in. A vicious circle of guilt and exhaustion that ultimately led to a month pause during which i couldn’t even look at my game. After one big and one smaller burnout (the other one was a reminder) i experienced, i learned a good lesson. Making a game is not a 100 meters sprint of passion, it is a 42 kilometer marathon that requires perseverance, determination and motivation. To stay determined and motivated we need to take care of our bodies and minds. Typical, a bit satirized, representation of a programmer is a skinny or a fat bold guy with glasses and a generally neglected appearance (stubble, lousy wardrobe and so on).

Turns out, there’s a grain of truth in every joke. This type of work takes an enormous amount of time and while not physically demanding it DOES impact the body, and with it the mind enormously. I am determined to avoid burnouts in the future, and here is what i can recommend to you to avoid them too.

Sleep Well

Developing games can be addictive, especially when you get into The Flow (or in the zone, as it is sometimes referred to). As i already have a full-time job and family, the flow usually comes late at night, when family is asleep and after an hour or two already in the works. I get completely immersed and have a distorted feeling of time and space, hyperfocus and increased productivity. If you think you can use this time well, make sure you can be absent from the work tomorrow so you can regenerate and have a good night of sleep. However, i wouldn’t recommend doing this often. It’s better to save that energy when you’re close to some goal that requires a large amount of work that you feel you must do in one push or you will lose focus if you split it in chunks.

Sleeping less than 6 hours increases obesity (you feel like eating more to compensate for lack of energy), chance of stroke, heart diseases and diabetes. Not to mention that you will be forgetful, need lots of coffee or caffeine drinks to make it through the day and be irritable as hell. Depression also creeps in. Make sure you sleep at least 7 hours and try sleeping in on weekends if you can.

Eat healthy 

I know it sounds obvious and like a cliché, but if you are mid thirties like i am, this fact needs to be repeated all the time. Make time to prepare a healthy, balanced meal. Eat vegetables, fruits, fish and meat. Besides making your own meals is the healthiest choice of all, it helps rest the mind by physically and mentally distancing you from computer. I find cooking relaxing and sometimes similar to long bicycle rides when my mind wanders off.

Drink water and tea, not sodas full of sugar. Recommendation of 2 liters of water per day is not a fad, your body requires a lot of water to function efficiently. The first sign of not drinking enough water will be a headache, so if you’re not feeling well, try taking a bit of water, you probably forgot to drink it for hours. I like dropping an effervescent 1000 mg vitamin C drop in the water, it’s much more tastier and you can’t get enough of vitamin C, though the higher your intake is, the more you will excrete. Linus Pauling’s “How to live longer and feel better” (he was a Nobel laureate in chemistry) is good on this subject, he took extremely high doses of vitamin C and lived to be 93.

Avoid too much caffeine, it actually makes you harder to concentrate if you overdo it, makes your brain foggy, causes caffeine crash and messes up your sleep quality when taken too late (if you manage to fall asleep). While we all love coffee as a stimulant, don’t forget that it is addicting and withdrawal symptoms can last very long, so it’s best to consume it in reasonable amounts.

Exercise

Besides sleeping enough and eating healthy, exercise is one of the most important things in whole thing of staying mentally stable when working on a game.  Get your juices flowing, ride a bike, pump some iron, run, cross fit, whatever makes you sweat. You will feel better, happier, healthier, have more energy to work, need less sleep, wake more rested and most important of all, have your brain functioning better due to improved blood flow. If you are like me, sitting in the office for 8 hours staring at a screen with (like most of us actually) and then doing that again in the afternoon, be realistic, it does horrible things to your body and mind and you must be fit to endure it. Besides back, neck takes the biggest hit, directly diminishing blood flow to your brain, causing headaches and brain fog. I found that the aerobic exercise works best for me (cycling and running). The repetitivness and the moving scenery clears your mind with the goal of acquiring mental void.

Don’t forget friends and family

Life doesn’t just stop because you are working on something that takes an enormous chunk of your spare time. You’ve got a family to spend time with and take care off and friendships you have to cherish. Socializing helps to take the mind off of your work, relax or perhaps vocalize the things that worry you or you are having problems with in your development. Even if someone is not into that, a fresh and naive look at your problem can be an eye opener.

After all, friends and family is all that matters in the end.

Take days off

No matter how great your passion and motivation are, being involved in anything 24/7 is just not good. You will get saturated, lose objectivity of your work and ultimately repelled by the sole sight of computer. Make goals on which you are working on, and say to yourself “when i finish this boss design, i’m going to treat myself with 3 days off”. And do it, feel satisfied with the work you’ve done and enjoy in your days off without guilt because you deserved them.

Relax (away from screen if possible)

Since you are probably already a full-time screen starer and you stare some more when you get home, i recommend you get some relaxation that doesn’t include staring at any type of screen. Cooking is a great way to relax, walk your dog without your smartphone, pet your cat for hours, read a book or a magazine, make a bubble bath, lay on the floor and stare at ceiling thinking about nothing, ride a bike out of town. It’s all relaxing and helps soothe your exhausted and work saturated mind.

Work on something different

If you really feel the need for working on your project, switching between the things you do often helps to avoid saturation. When i got bored of working on enemy waves, i switched to searching for sound effects and making some music. This development blog is also part of my avoiding burnout by doing something different. When you get sick of coding you can do some drawing if you’re apt at it, making music, writing a storyline, whatever jingles your bells. Just make sure you track your goals and don’t spread yourself too thin as it lowers the productivity and quality of work.

Managing it all

That’s all nice and dandy, taking care of yourself, but when you will find the time to work on the game with all this relaxing, exercising and cooking? It’s up to you to figure it out and integrate it into your lifestyle. It’s probably not going to translate into a lot of work hours, but what matters is the quality of those work hours. Most helpful thing if you are not able to work regularly on your game (i.e. have a family and a job) is to run a development log. Not just any, but a very tight one, with clear goals cut into smaller chunks you can handle and work on whenever you can grab some spare time. Besides knowing where to continue with your work after a few days of AFK, it will be motivating to track your progress. I’ll probably write more about it next time.

Stay healthy and take it easy!

Appendix 1

Thanks to the encouraging critique from folks at reddit/r/gamedev i decided to update the article with some quantification of the problem. Being an already a full-time employee, hour tracking of work done can be tedious when working irregularly and takes too much time in my case, but i had a more or less regular work schedule before the first big burnout to prove that it’s simply not worth it and you should respect your body.

Let’s say i worked on the game for two hours and on top of that extra two hours every workday of the week. Those hours were always, as mentioned in the article, late at night, after full 8 hours of work, when i am already tired and my work efficiency is largely decreased. Every workday i worked an extra two hours led to a total of 40 hours of sleep debt (since the only time i could afford was borrowing a chunk of sleep). That comes to 5  nights of good sleep monthly or whole two months per year! Imagine not sleeping for an entire week per month or not sleeping one night every week of the month. That leaves horrible consequences to your mind and body.

Every one of us has a different organism, gender, age, need for sleep, physique that can withstand more abuse than the other, so it’s quite difficult to determine someones need for rest. Being a 34 year old male, some general proposition is not less than 7 hours of sleep. That can be an ungrateful number, since i usually don’t feel quite rested if i sleep under 8 hours of sleep, but let’s take that as a general rule of thumb.

If i worked an extra two hours per night and cut off my sleep for two hours, i gained 40 extra hours of development per month. When you look like it’s great, almost 500 hours per year, that alone is a figure that can net some serious results. But how was the quality of that work? Being already exhausted, we can say that it was 75% efficient compared to a workload when i was fully rested. There’s stuff to work on that don’t require much concentration or brain power and there’s not much efficiency deficiency on those, but there are some intensive tasks (writing new mechanics, creative tasks etc.) that need a lot more mental power to be done efficiently and that brain power is already spent. I reckon the diminish can go up to 50% on that one (i was really struggling on creative stuff when i was working late nights), so we get down to the number of 75% on average.

So, we have 75% efficiency workload of 2 hours, which comes down to one and a half hour of full efficiency work. “That’s still ok!” you think. As the month goes by, it diminishes even more, due to increased fatigue, frustration and saturation by work but let’s leave it at the figure of 75% for an easier calculation since you used weekends to sleep in and get some of that sleep debt back.

After a month of burning out, you are already overwhelmed by the exhaustion and you tell yourself “Alright, i can’t take it anymore, i need a break”. You gained 30 extra hours that month and you deserve a rest. How long will it take you to recover depends on many factors. If you already have a job and a family, you will find that all of that itself is quite exhausting by itself. You take a week of break (two weekends and one workweek) and during that time you lose 10 hours of development, so your net gain is now even lower, it’s not 30 hours, it’s 20 extra hours. You worked 40 extra hours for a month to gain only 20 hours of extra development time and the chances are you are not fully recovered at all! Not only that, you distanced yourself from the project and it will take some time to get to continue where you left off.

Those are some simple maths that may prove something else of what i’m trying to prove, but it was a bit different in my case. For me, it took a month to recover after that kind of crunch and i didn’t fully rest. After a month! When i got back to the project, i didn’t know where i stopped and what should i do next and i still had a feeling of not being quite ready to keep working. I simply needed more rest. Not to mention the fact that i was eating more (especially late at night which is bad by itself) because i was constantly tired, getting fatter, weaker, had no power to workout at all, had a lower quality of sleep for not respecting the usual times of going to sleep and getting up and drinking too much coffee. All those symptoms didn’t get away after a month of resting by doing absolutely nothing except going to work where i was equally as useless. First the guilt and frustration comes in, for being weak not to work on the project, then depression usually knocks on the door. A depression so severe in my case that it took me three weeks just to snap out of it and start feeling a bit better about myself.

There are always times when you can push yourself to the limit and find an excuse for it. Whether is it “I just need to punch in the foundations and it will be easier later” or “release time is near, i have to give my best” at the end of the day it’s just not worth. Extra hours in a profession that needs a lot of time investment by itself, is damaging to your body since you are practically not moving for a lot of time and requires your brain to be fully rested are just a drop in the sea compared to what you are losing in the long run. The damage you do to yourself is usually not possible to repair fully, especially if you are not in your twenties when you could handle a lot of abuse and just keep going.

Dev Log #4

Dev Log #4

The Anatomy Of A Roguelike Endless Mode

Endless Mode, for now, will be the backbone of the game. I don’t much like the term, but let’s call it Roguelike. For those not unacquainted with the term, it’s pretty simple. The basics of roguelike games are permadeath (which means you start all over when you die) and procedurally generated levels. Procedural is basically a fancy catch-phrase for controlled random. It means that the levels are made by parametrized procedures that keep the random factor under control by defining the aforementioned procedures, certain value ranges and all sorts of parameters you want randomized. Anyone ever trying to make a completely random piece of any sort of art, be it visual or sound, knows that it usually turns out horrible. With the assistance of parameters like harmonies and scales in music, or color palettes, fractals and similar stuff you can get bettes results, but without the human input it’s usually a meaningless chaos with only glimps of something human-like.

Then what is it good for you ask? Well, with proper parametrization, you can get a gameplay experience that is different every time you play the game, yet it has the same essence and feeling. How does that work in my game, more precisely, in the endless mode? The most obvious thing that can be parametrized is the appearance of enemies on screen, so how do we do that?

Triggered Spawners

For spawning enemies, we need spawners, predefined locations on the screen where the enemy ships appear. Since we want the illusion of ships flying IN the visible part of the screen, spawners are set OUTSIDE the visible part of the screen, just a little bit beyond camera frustum. There are a total of 20 spawners, 5 for each side of the screen, and each of them spawns enemies by the command sent to them. That command, in the form of a triggered custom event (hence the name Triggered Spawners), is chosen randomly by a set of rules.

Rules are not made to be broken

In opposite of the old saying, rules in roguelike game must be well designed and not broken, unless you want your whole game to be broken. A tight set of rules need to be implemented to the enemy spawning system for it to be challenging enough, but not too hard and various enough, but not too random. So besides the variety, by making the rules for a procedurally generated Endless Mode i came up with something i call the Adaptive Difficulty System. Here’s how the whole thing works:

You start the game with 0 Experience Points (the first variable), empty Enemy Value Pool (the second variable) and empty Enemy Array (the third variable, let’s call it Enemy Counter from now on).

Experience points are the core to the system and a lot of stuff depends on them:

  • You earn them by destroying enemies.
  • Enemy Value Pool is the value of all enemies present on screen. When they appear, their value (based on their characteristics, HP, weapons, etc.) is added to the pool. When they are destroyed or they leave screen, their value is subtracted to the pool. The Enemy Array is simply a counter of the enemies present on the screen, when the enemy appears, it’s added to the array, when it disappears by means of leaving screen or death in flames, it is removed from the array. The thing is, Enemy Value Pool has a limit that is based on your experience level and it is raised higher as you earn more experience by destroying enemies.
  • Trigger for unlocking more complex and harder waves, new types of enemies and upgrading already unlocked enemies.
  • Trigger for bosses appearing, and transports with pickups appearing (that means no level is of the same length).

Enemy Value Pool works in conjunction with both experience points and the Enemy Counter and it is crucial for the difficulty level adaptation. The game will never spawn more enemies than the pool can hold, so it ensures a gradual progression in difficulty based on your skill. If you’re not such a good shot, experience will rise slowly, and with it the pool size. If you are a hotshot and hit ’em dead on the spot, you will progress much faster, get upgrades much faster and get to the bosses faster.

So what’s the Enemy Counter for? Тhe Enemy Pool Value has a certain limitations without it. You can have a pool half empty, but a lots of small enemies on screen that already pose a challenge by sheer numbers. Based by Enemy Pool Value only, the system will start an event of filling it up by spawning more enemies. The Enemy Counter serves as a fail-safe system against this. Instead of spawning more enemies, it will either delay further spawning if the number of enemies it too large, or perhaps launch one big enemy to add some variety to the situation.

Simplified Schematic of Adaptive Difficulty System
Simplified Schematic of Adaptive Difficulty System

Enemy Waves

As stated before, enemy waves are spawned in a controlled random manner, featuring procedural and hand-crafted elements. Procedural elements would be random number of single enemies moving on their predefined agenda or via paths with their numbers and type defined by experience points, while hand-crafter ones are squadrons.

Squadrons

They have the largest number of variety, but they can be painstaking to make if a large number of ships is involved. For example, this is a basic one, Marine Carrier in the escort of five Provokers, six ships total.

A typical representation of hand-crafted squadron
A typical representation of hand-crafted squadron

Due to Unitys limitation of nested prefabs, i can’t just pop them into scene view and save the whole squadron as a prefab (which would be really awesome and speed things up), instead i have a prefab which instantiates ships on defined coordinates in local space. That needs a lot of tweaking, entering values manually then pressing play to see where they are actually positioned. In the whole process, waiting for Unity to start the game to see where the ships are spawned takes the most time. Obviously, the time spent is the largest con, but the pro is that i can simply replace prefabs in the squadron in a blink of an eye. That means i can change those Provokers escorting the Marine Carrier with another ships in only a few seconds, or even set each position to spawn a random ship, thus making the ships following the carrier different each time and even spawn different ones according to the players experience level.

When you take into account around 40-50 ships made until now, you get the idea how tiresome can sometimes be to make all these squadrons, but it keeps the game away from being a procedural generated crap, it keeps the randomness factor but in a structured way.

Random Number Range Single Enemies

Now this is the actual procedural generated crap that is to be avoided, but when used properly it functions great. What does that title actually mean? There are several enemy spawn points scattered all around the screen, by utilizing this approach, depending on certain variables, they will spawn single enemies that follow their own behavior, be it the regular “move forward and shoot” or something else. There are some cool thing regarding this. For example, i can spawn 1, 2 or 10 ships in a random pattern based on the players experience level or number of ships already on screen. They act like fillers, we already have one or two squadrons on screen, so let’s drop a few more small baddies that do their own thing. It also keeps the players on toes since they don’t know what to expect. A horrible drawback is that things can get too random if not controlled by various parameters that need to be finely tuned, like mutual distance that avoids overlapping the sprites.

Enemies That Move Via Paths

I’m sure you’ll agree that the game would be very boring if all the enemies would just move forward towards players side of the screen, no matter how many types of them there is. Using paths to move the enemies further deepens the variety and the semi-randomness factor of the game.

Obviously, paths can be used for both Single Enemies and Squadrons. They work great for single enemies since we can set a wave to spawn, let’s say, 5-7 small ships and then use a path that’s branching, like this:

Enemy Waypoints
An example of a branching waypoint

In this example, when the ships get to the first waypoint (purple square in the upper part of screen) they will do a check which will apply random branch choice, some will keep moving forward towards the left part of the screen, and some will circle around and go back right, or maybe sometimes we’ll set them all to follow the same path, so for a path like this, we actually have three outcomes: all follow path 1, all follow path 2, all branch random, which is flexible and great.

Using paths in Squadrons take a bit more time to work on, but they add further variety to squadrons. The Provokers following the Marine Carrier in the first picture may spread or fall back after a while.

Another important option that using paths gives is the easing of movement. Ship may start moving slow, than speed up while moving down the path. Or other way around. That can be randomized to, per ship, squadron, or a whole wave. It gives a lot more natural feeling to movement since ships moving at the same speed constantly may feel mechanical and boring.

Easing types that allow for more natural movement
Easing types that allow for more natural movement

 

In Out Expo Ease type in action
In Out Expo Ease type in action

Utilizing all this stuff drives the game away from the classical “memorize the pattern while moving on rails” type of play. It takes a lot more time to work on but definitely keeps every game session exciting and fresh and rises replayability to a whole new level. Unfortunately for some, and in contrast to a usual Roguelike practices, not using seeds for procedural generation means you won’t ever be able to replay the game you just played, but i see it as a great thing.

Further randomizations

While not essential for gameplay itself, backgrounds are randomly changed with each level. But what IS essential for gameplay are the Random Events that come with some of the background. They are created in a brief moment of whiteout when ship enters the hyperspace after defeating the level boss and further improves the challenge and replayability. Some of those include meteor rains, ion storms or asteroid fields, adding up to the difficulty, variety and that juicy bonus multiplier.

Weapon upgrade system overhaul

Last, but not least important is the overhaul of a weapon upgrade system i spoke about in the last devlog. After a few weeks work it turned out that the weapon pickup and upgrade system is not functioning really well when handling the pickup after the first weapon switch. I refactored some array related stuff regarding the active/inactive weapon status and now it works like a charm.

Weapon Upgrade System Rehaul
Weapon Upgrade System Rehaul

It can be further improved by introducing a case-switch instead of all the yellow colored states which i will do in the next iteration. It will further simplify the machine, but i don’t think it can go simpler than that, at least using the state machine.

Dev Log #3

Dev Log #3

Intro

Turns out that thing aren’t always simple as they seem at first glance. I spent more time than planned on overhauling the weapon pickup and replacement system i wrote about in the previous dev log. Apparently, despite the system being laid out well, there were some hurdles that appeared.

First of all, the weapon switching system that was meant to be extremely basic and function by simply activating and deactivating children objects (weapon objects with firing FSMs) on the gunpoint of the ship proved too common for the concept of weapon equipping, upgrading and dropping during the game. I upgraded the system and while it’s very complicated and probably can be laid out a lot simpler, it works as intended.

The setup

Upon starting the game, Player is spawned, its child Gunpoint, and Gunpoint children, Basic Weapon Object (Level 1 out of 5 weapon) and Empty Weapon Object. You’re probably wondering why would i put something like Empty Weapon when it’s not even used, but we’ll get to it. Every Weapon Object has two FSMs, Main FSM, used for the upgrade system, and Firing FSM, used for firing the weapon. Gunpoint object stores the Weapon Switch FSM. Bear in mind that Weapon Object can also be Weapon On Ship, or a Weapon Pickup, depending on the state in which it is and the fact that Player can have two weapons equipped, but only one active at the same time.

Weapon Upgrade System – how it works?

Main FSM controller on the Basic Weapon Object enters the first state. It searches for the Gunpoint object (place on the ship where it will be spawned. Search is done by tag, since it is quicker than searching for it by name). When it finds it, it stores it in the variable. By checking if the Weapon Object is childed to a Gunpoint or not, the Main FSM is branching in two directions, which determines if it’s really a weapon equipped by Player, or a Pickup waiting to be collected.

Shorter branch is executed is if the Weapon Object is a child of the Gunpoint object. It is then stored in the Weapons On Ship array, and the Main FSM finishes it’s job for now. That means that it is a weapon equipped by Player and it can be fired.

If it is not childed, it means it’s a Pickup (drifting in space, waiting to be collected), its Firing FSM is disabled, a child which is an animated circle indicator for easier visibility is activated and the state machine starts its next event.

Weapon Object starts measuring distance from the Player. When the distance drops below defined value, Weapon Object can receive the key command from the Player, otherwise, it’s non-responsive to key press. In game terms, when the Player hovers over the weapon, by pressing key following states can occur:

Simplest case occurs ff the same weapon type of maximum upgrade level exists on the ship (checked by iterating through the Weapons On Ship array). “Weapon is at maximum upgrade level” message appears, the pickup eventually leaves the screen and it is despawned.

If the same weapon type of lower upgrade levels exist on the ship, it is upgraded. If the pickup is of the same or lower level than the weapon on the ship, the weapon on the ship is upgraded by one level. But if the pickup is one or more levels higher than the weapon on ship, the weapon on the ship is upgraded to that level. So, you get a pickup and it upgrades your weapon by one or more levels and it disappears. In game terms, it sounds simple, but actually there’s a lot of mechanics behind it.

For example, Player is equiped with Level 1 Weapon, and there’s a Level 1 Weapon Pickup which we collect. Level 1 Weapon Pickup iterates through the Weapons On Ship array, and it finds the Level 1 Weapon of the same type. It gets the position of the Gunpoint object, spawns Level 2 Weapon and adds it to the Weapons On Ship array. It also checks if the Level 1 Weapon in the array has its Main FSM enabled or not. If it is enabled, that means it’s an active weapon (we’ll also get to it when we get to the Weapon Switching mechanism), which means that the Level 2 Weapon that is spawned should also be active which is done by activating Firing FSM on Level 2 Weapon nad adding it to the Active Weapon array (needed for the Weapon Switching mechanism). Firing FSM on Level 1 Weapon is disabled, it is removed from the Active Weapon array, removed from the Weapons On Ship array, Level 1 Weapon equipped on ship itself is despawned and Level 1 Pickup is finally despawned at the end of the last state. If the Level 1 Weapon on ship is inactive (its Firing FSM is deactivated), the Level 2 Weapon also spawns with its Firing FSM deactivated, but is not added to the Active Weapon array.

What happens if the Player is equipped with one or two weapons that are different from the pickup?

Things get a bit complicated there. If Weapon On Ship array does not contain any of the levels of the Weapon Object that is the same as the Weapon Object pickup, a Replace Active/Replace Empty state is entered. Remember the Empty Weapon object from the setup? It is used as a placeholder when picking up a weapon that is different from the basic equipped weapon. By iterating the Weapon On Ship array and finding no weapons of the same type but finding an Empty Weapon object, it is simply despawned, removed from Weapons On Ship array and replaced by the picked up Weapon Object. Since it is not active, spawned weapon Firing FSM is also not active, thus not added to the Active Weapon array.

A different Active Weapon acts similar to an Empty Weapon object if all slots are taken. It is removed from the Weapons On Ship array, removed from the Active Weapon array, deparented from the Gunpoint, its children activated (circle indicator that makes it visible more better on screen), and the pickup is spawned on the Gunpoint. As i said in the beginning, whenever a Weapon Object spawns, it immediately checks if it is a parent of the Gunpoint or not, and then added to the Weapons On Ship array or not.

Switching Weapons

Finally, switching the weapons. First we need to make sure that the Player can’t cycle between the equipped weapon and the Empty Weapon object. As long as the Empty Weapon is in the Weapons On Ship array, cycling is not enabled. When it is no longer contained in the array, Player can freely switch between weapons. Every switch gets the first and second index numbers of the Weapons On Ship array, stores them as Weapon 1 and Weapon 2 variables, enables and disables Firing FSM on them, adds the Weapon Object with enabled Firing FSM to the Active Weapon array, and removes the Weapon Object with disabled Firing FSM from the Active Weapon array. We need the information about the Active Weapon so it can be replaced with the pickup that is different from it. That enables the Player to upgrade the weapon of the same type as the pickup on ship whether it is active or not, or select which weapon will be replaced (if both are different from the pickup) by simply switching weapons to active or not.

Complete system for upgrading and replacing weapons. Thing is - every weapon level object needs to have one of these.
Complete system for upgrading and replacing weapons. Thing is – every weapon level object needs to have one of these.