And we’re back (for real)

So, I know I said “my bad” last time, and that was six months ago.  But, Labyrintheer development has actually kicked back off and progress is being made.  Prior to giving it a break, I had two nagging issues that I couldn’t overcome.

#1 – the small one.  All chests that could be looted (advanced props) have a model and animation path that starts with them open (sort of in their T-pose).  The first thing that happens on instantiation was that they close, and in doing so, play the appropriate sounds.  It was a loud and obnoxious thing – small, but annoying.  Anyway, that’s been dealt with.

#2 – the big one.  Both the player and mobs have evolved over my time with Labyrintheer. They started with CharacterControllers because, well… they’re easier in a lot of ways.  But, despite literally weeks of effort, I couldn’t prevent the player from climbing atop the gelatinous cubes when they pushed against one another.  It was frustrating.  And it appears, in part, to have been caused by having both a CC and a Rigidbody.

I started using the Rigidbody because with only CCs, the mobs would push the player around too easily.  The fix, at least so far as planned, is to remove the CharacterController components, wire all the player controls to appropriate Rigidbody physics, and probably just not use CCs anymore.  It’s not a huge amount of work, just need to get physics movement working (and feeling) right.

All of this is coupled with trying out Unity’s Collaborate rather than my existing git repo.  I’ll probably maintain git, at least for a while, but Collaborate really does seem pretty nice, and I don’t have to worry about git vs git-LFS.  Let’s see how that ride goes.

Otherwise, I plan to maybe use another platform for bug/issue/work item tracking.  Anyone have any tips?  I’ve been toying with #Slack, and trying to find a plugin, perhaps, that would work for such a thing. Conclude would be okay if I didn’t mind eight million channels (one for each issue).  Maybe there’s a better way.

Anyway, for what it’s worth, I should be posting here much more often.  Thanks for hanging around!

Unity Profiling for Fun (and Profit?)

For those who may have been following since before this blog began, you may have seen the Iceglow Gel death sequence that includes the possibility of spawning smaller Mini Iceglow Gels.  This was, by and large, a stroke of sheer genius on my part (yeah yeah yeah, just let me have this one).  It seemed like a cool idea and has led to some other cool ideas for deaths with other mobs.  In fact, each mob has a DeathScript requirement, even if it’s just to, you know… die.

But this has also been a thorn in my side.  When an Iceglow dies, there is a major stutter before the new minis are spawned in.  I finally decided to toss up the profile to see what was going on, and decided to write this brief post on profiling, because damn, it’s handy!

For those new to Unity or development, the profiler is a pretty common tool used to “debug” the actual running game.  It can attach to a development build for better and more accurate profiling, but if you’re simply looking for bottlenecks where the definitive time and resources aren’t as important as discovering the spike, you can also simply attach the profiler to the editor itself.

Ice Glow Death Profile 1
Ice Glow Death Profile 1

This was a capture at the time of the resource spike right when the Iceglow dies.

Ice Glow Death Profile 2
Ice Glow Death Profile 2

The details of CPU usage show that the >1s spike is caused by the PhysX core baking the mesh for the minis.  I was hoping that, since this was running in a coroutine, that it wouldn’t impact the whole of the game.  Maybe I’m doing it wrong (or, at least, not the best way).  Maybe I can pre-bake those meshes.  Maybe I can use simple colliders instead (a cube is far easier to calculate).  I’m just delving into this, and I’m not sure what the best solution is yet (stay tuned for updates on that, or follow my plea for help), but for now, the profiler is my handy tool to figure out what calls are b0rking the game.

Easily as important as debugging code, and definitely more important for tuning, I can’t recommend highly enough learning to love your profiler.

If at first you don’t succeed, Google some more…

As a lesson, today I taught myself that sometimes your first (several) attempts to Google a problem just don’t do the trick.  For several weeks I’ve had an issue where my mobs just zoomed around like they’d been snorting magic dust, completely ignoring the values set for them with regard to speed, acceleration, et cetera.  It happened fairly suddenly, I wasn’t sure why, and many attempt to fix it failed.

I Googled this issue many times over the weeks looking for an answer.  Nothing relevant ever seemed to make it into my search results.  It became frustrating!

Then, on a whim, I searched once more for the answer, clearly using a better phrase, and Google’s magical algorithm finally decided to lend a hand.  Of course, the answer was something dumb on my part.  At some point, the isKinematic boolean flag on the rigidbody component became unchecked, which meant that the rigidbody and the nav mesh agent were in a race condition, both trying to control the movement of the mob.

But, NO MORE!  My gel cubes gracefully slog around the dungeon biome again, and the War on Magic has been brought to a halt.

One checkbox took weeks to resolve.  Probably a n00b issue, but a good lesson all the same.

Random Class, Singletons, and the “Big Debate”™ (does this sound familiar?)

A few weeks ago I wrote a VERY similar post about my Logger class and the debate over the use of Singletons.

I’ve done the same with my new randomization class, LRandom().  LRandom does several things under the hood, and is a singleton for a very specific reason.  First, I wanted to use it to replace the random class that Dungeon Architect uses during initialization of a dungeon or map.  In part because I wanted more control over randomization, and in part because I wanted all aspects to produce the same values with the same seed.  Previously, at least in earlier versions, DA would produce the same dungeon layout, but things like decorations and extras would not always be the same.

Additionally, I wanted the same random class to be able to control other randomizations during play: loot, die rolls, et cetera.  The current implementation uses a single System.Random instance, though I may extend this to have several – one for dungeon building, one for loot, one for mob AI, and so forth.

Also, the state of the System.Random is stored in a serialized file on exit.  This should, in theory and after a lot more work, allow one to pick up where they left off with the state of the randomizer where it was before.  The main goal here is to prevent “known randoms” with the given seed.  The first chest you run across won’t always have the same stuff.

The class also contains the original DA methods for NextGaussianFloat() and GetNextUniformFloat() to integrate without changing a lot of the DA code.  And lastly, it contains methods that allow the instance to be reseeded if need be, which is mostly good for debugging, but may have benefits during runtime as well.

So, currently, LRandom() and LLogger() are two singletons that I’m using that have proven very beneficial.  If you missed my last post, or want to hear more about Singletons (the good, the bad, and the ugly, so to speak), check out this great podcast from The Debug Log- Episode 73: Design Patterns: Singleton.

Logger Class, Singletons, and the “Big Debate”™

So I’ve spent a bit of time working on getting a logger class setup, which is rudimentarily complete.  This class currently just writes out to a file and also to the debug console in Unity.  It takes in a message, a module, and a severity.  I wanted to easily have access to this class from anywhere, but since it writes to a file, I also needed to ensure that there was ever only one instance trying to access the file at a time.  This, of course, led to the singleton pattern.

Now, even a cursory glance through newbie programming blogs and books can cause one to question why this is even a pattern to begin with – it seems that everyone says to stay away from them, and I kind of understand why you don’t want to overuse them.  The Debug Log has a pretty good episode about them here.

So, singleton was the answer, and it was setup nicely enough and it works, though I still need to make it threadsafe.  But… logging:


So, now it’s back to work on the game itself.  I have most of the systems in place to get a sample level up and running soon.  Yay!

Dungeon Layout Metrics

So, for the current branch of changes, I’m working on level layout, design metrics, and baseline functionality.  What does all of that mean?

Layout Metrics and Design
Layout Metrics and Design

In the above photo, I have a nearly perfect layout.  The spanning tree options have kept the start (blue dot – bottom right) and end (red dot – center) pretty far apart.  The blue dot is the actual portal where the player would enter the level.  The red dot is just a red colored portal, but that portal is a marker for where the boss room will eventually be.

Of course, since everything is randomly generated, no two levels will be completely alike.  Unfortunately, that means as I change things up or even hit a seed I don’t like, things can go south.

Too Much Spanning Tree
Too Much Spanning Tree

The above shot is with a bit more weight on the spanning tree node.  There’s still a nice long path between start and end, but there are also long hallways that loop too far around (for my taste, at least).  Actually, the above example isn’t awful, but these images are the same seed, the first with 0.05 spanning and the second with 0.15.  While the spanning value may be static on all levels, there may be some small fuzziness around those as well.  Trying to find boundaries is more of a balance than I expected.

Other than basic parameters, I’m trying to prevent barrels from spawning inside of walls:

Barrel Wall
Barrel Wall

Or in large groups that get in the way:

Too Many Barrels
Too Many Barrels

I’ll be working on better “torch flicker” – right now it’s a bit stuttery looking, and I’d like it to be smoother and look more like an actual torch.  Then a few more mobs, the boss spawn, and some more decoration for the level.


It’s been a bit since I posted last, but that doesn’t mean nothing has been happening.  There’s been some good progress on controls (which is actually kind of a pain in Unity), some work on mob AI (they attack now, animate properly, and even have sound), and some various fixes and clean ups in the code and the project base.

Additionally, I’ve started a second project that I hope will eventually be used in Labyrintheer, as well as be available for anyone to use on the Unity Asset Store.  More details to follow, but I’m hoping to have a really complete and useful package.  Only time will tell, I guess.

Lastly, the second project won’t consume all of my development time, so there should still be (semi-)regular updates on the blog about what’s going on.

Fun with shaders

After getting the debacle with my git repo fixed up, I decided to work on some shader stuff.  I’ve never made a shader before, so I started with some great tutorials Makin’ Stuff Look Good in Unity, a great series of tutorials for Unity devs.

I started out with the tutorial on Winston’s barrier from Overwatch and this is what I had:

Initial Fire Shield
Initial Fire Shield

It looked pretty cool, but wasn’t much different than the tutorial, and also the hex pattern looks far more sci-fi than fantasy RPG.  I made some modifications using temporary PNG assets that I reworked the RGB channels on and ended up with this:

Arcane Fire Shield
Arcane Fire Shield

Much better – arcane symbols work more nicely than the hexes.  Of course, this will be developed over some time to get a better effect, then slightly modified for different elements (there are 12 of them in the game).

Anyone following this at all might be asking: “why the heck are you working on shaders and effects when the game systems aren’t done yet?”  I think it’s a valid question.  Most blogs and books on game development seem to point to it being better to get functionality in, then make things look good.  There’s probably wisdom in that, and I’m sure it works for a lot of people – maybe most people.  But I thrive in chaos.  I also have a bit of the ADD.  And being a (semi-)solo developer, I have to really work on all of the things, so…  sometimes I jump around to not get bored or when I get stuck on something and want to revisit it later.  There’s nothing wrong with this.  Always find the work flow that works for you, rather than trying to fit yourself into the work flow you read or learned about.

Sometimes things just go wrong…

So, I lost 1-2 weeks of development time because I hosed up my git repository.  Anyone else ever do that?  Anyone?  *crickets*

Well, since the whole point of source control is to protect you from these things, clearly I did some very bad things.  Turns out it was a series of bad things.  First, I change my asset serialization to force text.  That part was fine, except then I had a failed merge and merge conflict markers got dumped into the files – which can’t happen with binary files.  At the same time, I was setting up LFS for binary files.  I’m not sure what I did wrong there, but LFS half-worked.  At some point files duplicated, went to LFS but then the pointers in the repo were overwritten by the original binary files.

At this point, I was hosed up good.  My repo was well over it’s limit, I couldn’t push anything (not that I wanted to), and was having a hard time finding a commit I could roll back to that was good.

Now, I have a working copy of my project.  But it doesn’t work for everybody, so something is still amiss.


At least it loads now, right?

Tryin’ a catch me settin’ dirty

I’ve been working on the core combat mechanics for the past week or two, and have finally got things feeling decent – at least to start with.  I wanted to do something modular so that over time it would not only be easy to tweak, but also easy to add additional features.  So, here’s a sample of what I have so far:


The base element here is the DamagePackage, which contains information about the raw damage amount (DamageArray – from each of the 12 possible elements of damage), the cause of the damage (DamageVehicle – e.g., weapon, creature, trap, environment, effect), any damage effects which would include damage over time (DoT) type effects, and any special effects from the attack (chance to be set ablaze, frozen, sleep, silence, etc.).

There is a slight error with the diagram above, as I’m typing this all out – the CharacterStats are brought in on the Talker and Listener levels.

At any rate, the DamagePackage moves to the DamageTalker, which takes in the attackers stats for any modifications, then sends the package along to the DamageListener on the attacked actor.  The Listener works in reverse, unpacking the information from the package, applying resistances and such from the attacked actor’s stats, then applies that modified damage package to the actor itself.

The beauty of this system is it’s flexibility.  The downside is that different components reside on different levels of the actors and their equipment.  For instance, on the player, the stats and the listener are on the root, but the talker and all of it’s constituent parts live on each weapon (or spell).  For a non-humanoid creature, almost everything lives on the root level.  Except listeners – the listener must always reside on the same layer that the collider lives on.  Well, it doesn’t have to, but it makes things worlds easier.  So…  this is something I’m trying to figure out.  Though honestly, I could probably package this up for the Unity Asset store once I get it all cleanly situated.  I’m happy with where it’s at now, but it has a LOT of work still ahead of it to be a nice, simple-to-use package.

DoLevelUp() function

Of course, the system needs to be set dirty whenever an actor’s stats change, or when weapons/armor are swapped out that might impact stats.