Browsed by
Category: News

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

Dev Log #2

Dev Log #2

It’s been almost two weeks and i’ve been very busy with my day job so i didn’t manage to spare too much time for game, but i finally finished (for me) a very complicated thing – upgrade and weapon switching system.

Player starts out with one weapon. During the game he can pickup a variety of weapons from destroyed cargo ships. The first time he picks up a weapon, it is added as a second weapon, and player can switch between them according to situation (bullet, energy and missile weapons don’t deal the same amount to normal, armored and shielded enemies). When another weapon appears as a pickup, two scenarios are possible: if the weapon is already equipped, it gets upgraded and the pickup despawns. If the weapon is already at maximum upgrade level, player is notified via on-screen message and the pickup stays where it is. If the weapon is not equipped, currently selected weapon is replaced (dropped as a pickup, while pickup spawns on player). While dropping the weapon is not very important in single player game and complicates the situation a lot, it is handy in 2 player game, where one player can drop a weapon for the other player to upgrade his weapon. The handy thing is that when a player drops, for example, Hyperblaster Level 4 and the other player picks it up, he’ll get the Level 4 Hyperblaster too, not level 1. Since there are (for now) 23 weapons in game and the only way to upgrade them (besides universal weapon upgrade pickups) is to pickup the same weapon, that will be very cool in terms of player cooperation.

Here’s a shot of an FSM:

Spaghetti coding
Spaghetti coding

Basically, when the weapon spawns, it checks itself if it is a weapon or a pickup (by checking if it is parented or not). If it is a weapon, that means that it is player equipped and it is added to the array and the variable is stored if it is in slot one or slot two (required for weapon switching during the game). If it is a pickup, distance check state is activated. Player can only pick it up if he is closer than a defined distance from it (by pressing space, so no accidental pickups are possible). When he picks it up, it iterates through the array to see if it will replace the existing weapon (if no weapon of same type is found) or upgrade it (if weapon of same type is found). If it replaces it, the existing weapon is dropped (which means it is despawned, removed from array, spawned on location of a pickup with its firing scripts disabled and pickup indicator enabled, while next level weapon is spawned on gunpoint with its firing scripts enabled and pickup indicator disabled).
Weapon switching is, compare to the upgrade and pickup system, a walk in the park. Stored weapons are simply activated/deactivated by pressing the switch key.

Scripting this thing alone would probably take a lot more time than it did, so using Playmaker did the job pretty quick since i can try something out in a matter of seconds, not waiting to write a couple of lines with risk of making syntax errors.

But, here comes the downside. Instead of making the script that can just be copied/pasted on all weapons (have in mind that there are 23 weapon with 3-5 levels each, so that comes to about a hundred prefabs, with more to come), i have to copy/paste an FSM to every weapon and tweak the variables in each one of them. I don’t have to tell you that if any larger scale fixes in logic are necessary when all the weapons are already prepared it will be a lot of work to change everything. Not to mention the possibility of making errors when managing such a tedious task.

One more thing i did is implementing the sprite atlas which reduced draw calls a lot, and boosted frame rate from 15-30 FPS to ~150. Now everything goes very smoothly. There are some hiccups, but those are due to extensive logging which is quite necessary in this phase. Swarm missiles got an overhaul too, now they’re flying nicely in a semi-random homing pattern, they way i imagined them to be.

Swarm missiles flying nicely in a semi-random homing manner
Swarm missiles flying nicely in a semi-random homing manner

Also, the artist guy did some weapons art for me, some will maybe change, but i thing they’re pretty good looking and quite different.

A selection of collectable weapons
A selection of collectable weapons
Dev Log #1

Dev Log #1

To keep the track of the work done, motivate myself and keep people interested, it’s time to start a Dev Blog. Here’s the first one for the work done in the last few days, enjoy.

  1. Design of the Swarm Missiles weapon. Basically (as the name says) it launches a swarm of small missiles from the player ship and every one of them tracks random enemy. It may require an overhaul to make them more random with some sort of unnecessary crazy loops to compensate for their number. The design wasn’t too tough, each missile has a random frontward direction upon launch and a small delay before tracking starts. Every few moments, they change the target they locked on to so they move randomly in a natural, swirly manner.
  2. Design of the Randomizer (work title) weapon which shoots a lot of particles but to compensate for their number they move slowly in a random forward pattern and are fairly weak, but can protect you from swarms of smaller enemies. Pretty useless against big enemies though.
  3. Design of the Shield with regeneration timer and connection to the shield integrity bar. Still needs connecting to the heat transfer mechanism (when you get hit, shield takes the damage, but your heat level increases, energy transfer stuff).
  4. Design of the Auto Cannon Drone. It tracks closest enemy, rotates towards it and fires. If no enemies are present, it stops firing. Oh, it also follows player of course.
  5. Design of the Ripper, basically a manual shooting shotgun that sprays multiple bullet in a cone, that was pretty easy to make. It shoots as fast as you can click, deals a lot of damage it all bullets hit the target, but it heats a lot, so i have to disappoint you if you’re a Starcraft player with million clicks per minute and plan to win the game using Ripper only.
  6. Design of the Flak Cannon. Like the real Flak, it has proximity activated “fuse”. At a certain distance from the enemy it explodes and blasts into a lot of small pellets. Great against small enemies.
  7. Design of the Proximity Mines. Regular mines just floating in space were designed a while ago, but i decided to put a bit more challenging ones. When you get near one, it shoots a laser ray which locks on to your ship (doesn’t damage it though) and starts slowly moving towards you until you destroy it. I also designed the EMP mines that will work the same way, but deal less damage and mess up your screen with glitch effects. Also updated the mines with random rotation and blinking red light so they’re a bit more interesting looking and easier to spot.

 

Dev Blog - Guided Mines
Homing Mines – slow but deadly