Sunday, 25 November 2018

Dimensional Knight Animation Anarchy

Remember this guy?


He is one of two Knight models which I customized into my Unstable Dimensional Knight enemies all the way back in summer (summer now a distant memory as I hundle under a blankie whilst freezing rain peppers the external windows). Dimensional Knights suffer from "instability", something most RPG and fantasy wargamers know affects inter-dimensional beings, and that's why parts of them kinda of warp in and out of existence. Whilst the models were good quality and rather (too) detailed - way more polygons than I need - I found that their animations were a bit lacklustre having not been based from motion capture footage. Not particularly seeing any mocap which I liked for a reasonable price commercially, to get some decent custom animations I decided to amalgamate their stock animations with some free mocap and rotoscoping - the latter being a horrbily time consuming animation but more exact than "best guess manual animation", at least for positioning large items like limbs.

And this is where total chaos ensued.

It didn't help that was now using three seperate armature rigs (skeletons and bones), what with the bvh format mocap files being different structure from the models' source files which were different from my generic animation rig. Now it's not too difficult to rename bones, animations and mesh vertex groups, except at some point quite early on, I changed the basic non-animated root pose - thus throwing all the rotations for animations off. Annoyingly I only realised my mistake towards the end, and with four variants of two models, ended up having to manually repose all eight enemy models individually by a mixture of copying coordinates and using the judgement of the old fashioned Mark 1 Eyeball. Between this and manually merging different animations together along with rotoscoping over other animated meshes and video stills created a huge gravity well which sucked in vast amounts of time and effort.

Eventually I had a two spawning animations were our Demonic Knight salutes or issues a challenge to the player, two idle animations with some weapon flexing, three attack animations, one leaping overhead special attack animation and various jump, fall, land and other animations.

 2 models, 2 idle animation poses, 4 colours

Then there was the slight issue of how to get this enemy type to move. If you are an "Inter-Dimensional Being" then walking seems like a rather mundane method of traversing the game world. Having them just ski along in their root animation made it look like I couldn't be bothered doing a movement animation so instead I created a floating animation. This also looked a bit unexciting at first, initially because the animation resembled the "T-Pose" that many models revert to when they are not animated. I changed this to create two seperate movement animations, one were the enemy holds their weapon in front of them a little like the holy pose that sculptures on the stone coffins of dead knights have, and the other were they are reaching out towards their target with one hand and raising their sword as a sort of challenge in the other.

To the models I added some extra effects to give them more of an other-worldly feel and an intimidating presence of power. One of these is a simple translucent cloud which looks like a particle effect but is actually just three rotating textures of differing intensity and colour. The other is an aura of power on the ground which is connected to the enemy's animations. This gently pulses when they are not moving, spreads and rises during their attacks, and shoots up to envelop the model when they move, making for a much more interesting floating animation. They model also elongates slightly when they move which makes them more intimidating. To the Knight's textures I added a bright animated outline to help with a shimmering glow around the edges and dropped the actual glow shader I had been using on the materials. This reduced drawcalls by a couple whilst reducing the need to draw an extra 27K mesh triangles. As one of the models was a 16K triangles, I decimated it automatically down to a more manageable 12K with no visual impact.

I created a new special attack for this enemy type which involves them teleporting close to a clear area near the player. They start their special attack animation of a jumping overhead axe swing and particle effects surround them and the position that they will teleport into to complete their attack. This gives the player 1 second of warning to get out of the way. Initially I also created an invisble collision shape into the area to block the player and other enemies from occupying that space but realized that it would interfere with how decals are positioned, so I swapped the collision mesh for a physics zone which keeps other enemies out of the area but can slow the player down if they enter it. This seemed to work rather nicely. Originally all of the Dimensional Knights had this special attack but as I based it off the movement phase rather than just the attack phase I realized that would cancel out directly hunting the player as an option to the enemy AI's thought cycle. Now only half the Knights have this teleportation attack whilst the others move as normal, either heading for the player's last position or following directly as a hunter.

Here's an early look at the Dimensional Knights in action before I had finalized their animations.



So that was the Unstable Dimensional Knights of level 7 completed. A tough slog which took far more time than I wanted ... but I say that every month when I write these blogs ...

So, what left? There are a few more enemy types I want to make. Going back to the old Monstrous Morris Men Wendigo style enemies, I want to add a nymph-liek character with a special attack that includes a dash through the player, however as they will share various animation characteristics with player characters, that is something to leave until the more monstrous monsters are done (rather than constantly going back and forth between things). So next up on the list of over nine thousand things to tick off are those of a more Cosmic Horror motif. Cue tentacles and Lovecraftian madness ... and Lovecraftian madness seems to be a good description of indie game development ...

Monday, 29 October 2018

Glowing Golems And The Curious Tale Of The Non-Invertable Bind Shape Matrix

Whilst agonizing over golem design followed by golem re-design, I had a mangled LOD mesh which resulted in a crash. Making a slight change to the mesh and re-exporting fixed the crash, but I also noticed a curious error warning in the console (which probably wasn't related).

bind_shape_matrix in mesh# controller is not invertible (may cause problems with skinning)

 Wut?

 A little bit of digging around the codebase led to these most useful code comments.

   // Some exporters (AutoDesk) generate invalid bind_shape matrices. Warn if
   // the bind_shape_matrix is not invertible.

Wut? 
 
Okay that wasn't very helpful. What would the skinning problem be (I had not noticed any) and how do I fix it for export from Blender3D? Alas, the interwebz were not particularly useful in  determining how to do this, so I started a process of elimination, based on the logic available. Deducing that many of my models were rotated and vastly resized soley using the armature, I eventually found that uncoupling the mesh from the skeleton, and manually editing the mesh to resizing, rotate and align it to the bones cleaned up this error message.

The downside turned out to be how many instances of this error there was. I have so far created a variety of characters which weighed in at ~110 seperate meshes, and 85 of them needed resizing and manually aligning - and as it was the meshes which required directly editing, I couldn't just snap one object to another - which is actually part of what caused the problem in the first place. At least it was an error caught before I got to the end of character creation, but it would have been much less hassle to have found this out at the beginning, possibly with some huge flashing warning than a few red lines in hidden amongst the jumble of text in the console soley during first importation.

Golems, golems a plenty

So this brings us to golems, and the constant redesign of the little blighters. Who would have thought that creating a vaguely humanoid shape out of clay/rock/earth would have been so complicated. The problem was, I didn't really like any of the designs which I came up with, thus creating a whole array of slightly different clay men ensued. Eventaully I went back to my first design and added glowing cracks. Initially I had these cracks animated, first with a pulsing effect which didn't seem to be very obvious, so I changed that to an animated one. This looked quite cool when they were not moving but became rather busy and not particularly obvious with them running about, so in the end I decided to keep the glowing cracks static.

I made a rather interesting spawn animation from which the golems are created from animated rocks gathering together and then fall away to reveal the monster within. It looked quite fancy having it happen over time but this is an action game so the whole thing had to be compressed into one second. Likewise when a golem is slain it collapses into it's constituent parts of rock.

Golems Spawing, pre-glowing cracks

In game, the golem is a small and heavy enemy, best suited to swarming the player. As they are made from earth/rock/stone/etc they are very heavy and cannot be pushed out of the way (at least not by the physically weak gun wielding, range-based default player character). Golem has death in Hebrew written on it's face - not that you can see this at the scale and angle, but hey it does.

I also changed the overall colour scheme of the game, getting rid of the greenish colour and replacing all of the HUD elements and user interface with an old blue colour I liked.

Green out, blue in

And here's  the golem level in action.


So far I have around 70% of enemies for levels done - not including level bosses, and of course there are a number of player characters to yet create and replace that yellow cube. I am leaving those until last as they are all a variation on a theme and will share the same skeletal structure for animation.

Next up is organizing animations and data for attacks for my old "Dimensional Knights".

Soon ...

Friday, 28 September 2018

Jugular Spurtiness, Engineered Brutes And Boolean Modifiers

Scorching heatwaves have faded into Autumn and the oversized fan I went to so much trouble to get hold of is now packed badly into it's box. At one point I was swarmed by the "Idea Fairy" for other game ideas.

Actually footage of me defending myself from new game ideas

Back on the gamedev front, I added GUI markers to the interface for when the player gets a temporary boost or decline. Previously such events were heralded with an informative element saying what had just happened and how long it would last for, but there was no actual timed element to let the player know whether it was still on-going or had stopped. I decided to change that with a simple "up arrow" icon for boosts next to Experience, Health, Energy and a "running man up/down arrow" for temporary speed changes. Once the temporary change is over, the icon vanishes. Having a speed boost also now protects the player from slowing attacks.

Boosts!
I also gorified the decapitations. Not only do head explode and blood splatter but now jugular veins spurt and throw extra splatter on to the ground near the neck when the corpse finally comes to a halt.

Boom! Headshot!

A long time ago in a galaxy far, far away I had coded some custom homing missiles. However they would cause a crash if their target was deleted - even though I had told them to reset and lose height if there was no target.The hacky workaround was simply not to have any deceased target permenantly delete faster than the lifespan of a missile. Recently I realized that I had failed to add a "isProperlyRemoved" for the target deletion check, and this fixed the crash.

Getting on with modeling and coding new enemies, I eventually found that Blender 3D has a csg style tool called "Boolean Modifier". This can slice, delete and merge two different meshes. Annoyingly I found all of this information out after I had been doing the whole thing manually ... (insert autistic screeching here).

 Nobody Cared Who I Was Until I Put On The Mask ... and then beat the player to death ...

Previously I had modeled a plasma-rifle wielding alien based on the old Manits Man character, and named it the "Kralmok Warrior" after the name of the weapon it carried. This enemy has now been renamed again as the "Hive Warriror" - which is a little easier to say, never mind spell as I found "Kramlok" appearing in my code quite often. The Hive Warrior is a level 5 enemy and is now accompanied by an Engineered Brute.

Brutes with a Hive Warrior and a human sized zombie for scale

The "Engineered Brute" is a genetically engineered ... er ... brute. A large and relentless enemy with a melee attack which whilst slow, recovers quickly. They are the sort of solid enemy which the player will find difficult to push out the way, especially the default ranged weapon (gun) based player character. It spawns by teleporting in just like the Hive Warrior and gives out a gutteral snarl to announce it's entrance in overly dramatic style.

Dramatic Entrance Is Dramatic

Now that I am at testing level 5 enemies all together I realised that I had not created an easy function for this and instead would have to play through the other levels first. Which is fine apart from the time taken - unless I get chomped on by giant spiders in level 3 and it's all game over and start again. To rememdy this I coded a little function which starts the game at the desired level with the player upgraded through typical experience leveling and powerup collections from previous levels.

My Face When I Didn't Do This Earlier ... 

10 whole minutes of testing combat against Level 5 enemies. I got pwned in the 10th minute and never escaped the level.


So, that was the month that was. I fixed and tweaked loads of stuff, got level 5's enemies modeled, animated and working, and found a whole new and easier workflow inside Blender for modeling.