Archive for category Unity Game Development

Global Game Jam 2010 Post Mortem

Maid of Dishonor. Global Game Jam 2010 (click to play in browser).

This year we attended the Global Game Jam with the Albuquerque chapter of the IGDA.  It was the second game jam we’ve attended but the first global one.  Last summer our local IGDA held a game jam in the same format as the global one, but just locals.  I’ll talk a little bit about the differences I felt between the smaller venue and the larger one.  But I want to spend more time talking about some of the lessons we learned about the process of building a game in 48 hours between the two sessions, and what we learned about this particular game as we were developing it.

One of the things that stuck out to me doing the global version was that it doesn’t feel all that much different than the local version.  We really only interact with the people at our location.  It’s too bad because there were ustreams set up, apparently, but people only really watched some streaming dogs (from what I knew).  I’m not sure how to achieve a more global feel.  There was one point where we heard a weird horn coming in through the speakers and went to investigate and discovered that we were watching Iceland.  More of that would have been pretty entertaining, but also distracting from the task at hand, no doubt!  I wonder if it would make any sense to allow people to work across country borders?  The time limits would be strange, but the open source community does it often enough it might not be impossible to consider.

Despite all the differences I didn’t notice there was one I did notice a great deal.  That is that in both cases the global and local version, our ideas (from each group) were well contained, and by the end familiar.  This is great because even though people are working on different projects, we can feed off each other for ideas and there’s a lot of similarity that comes out in the various projects (but also different perspectives on the concept).

When there’s a global group to look at you suddenly discover other cells which have come up with a completely different sort of convergence.  It’s a bit of the best of both worlds, you get used to seeing and thinking about what the people around you are working on, but when you go look at the global submissions it’s more than a little surprising what other directions are discovered.  I imagine for the organizers looking for great ideas coming out (and I’d love to see a summarization of some of the best, most original) it is a well-spring of thought.

The more interesting differences between the two sessions for us were in the game itself.  For the two of us, there was no difference in how the 48 hours played out: Friday mostly planning, Saturday work to death, Sunday cleanup race to the finish.  Except this time we had the experience of hind sight.  We came in with two very important personal constraints.  The first was that we were going to use Unity instead of Pygame which we did last time.  We both know XNA and other systems (like Ogre and Crystalspace) but Unity’s editor is simply one of the best.  It makes things very simple to get working quickly, and we wanted to spend time thinking about the game and not how to make some code work (I’ve got a day job for that :).

SnakeCrush. Written in Pygame for the NM Game Jam 2009 (click to download source)

When we were doing pygame, we spent most of Saturday building an engine.  The 3-layer parallax motion system I was trying to develop did not work out (and probably wouldn’t have the way I was thinking of it) and we ended up going with a more “Double Dragon” style system on Sunday.  Compared with Unity, we had the basic game working on Saturday morning.  In fact, we had the basic game, walking around the room, working on Friday night after we spent a few hours throwing the models together.  We finished up the Eye, the first camera (in the lamp) and the mechanism for clicking on the lamp and the picture to determine whether you’d win or not, but more on the design (and subsequent evolution) later.

The other constraint that we went in with was to not do physics.  Despite that Unity makes it fairly easy to get physics working, there is still so much tweaking that’s involved in getting the numbers to work out, especially in terms of friction and collision response that it either requires being too careful with measuring to “act right” or spending too much time twiddling numbers until it “looks to act right”.  Although I was personally tempted several times to just turn on physics (let you move the furniture around, bump into the desk, etc) it made proving out the mechanism much easier.  Instead of having to detect some complicated motion which is “bad” we simply defined moving using the right mouse button as “bad” and there was no question.

But for a more advanced design, perhaps having such subtle movement in the presence of the Eye would be an interesting twist.  What if instead of having to explicitly turn the lamp away from the portrait, a player could instead vacuum up against the desk and bump it cause the lamp to fall.  This sort of complexity may be an interesting take in the future, but first to discuss the evolution from the start.  The game we finished on Saturday morning (and uploaded to the site) was the simplest possible concept:  Either turn the lamp before moving the portrait and win, or turn the portrait without first turning the lamp and lose.  The point of the game was to use the eye to learn that the camera was in the lamp and thus realize that you must turn the lamp first to clear the portait.

While this was useful, it’s really not an interesting game.  So we went to lunch to discuss what it would take to make it better.  We had a few thoughts.  One was to install multiple cameras, so that we would have cameras watching cameras and more of a puzzle to determine how to move objects while off camera so as to clear the space.  To make it interesting (and because we skipped physics) we made it so that when you moved one object with a camera in it, it might point at another object with a camera, thus increasing the challenge.  You’d have to move object A (which is pointing at B), move object B (which is pointing at C), move object A back (since it is currently also pointing at C), and finally move object C to clear the goal.  This is what we ended up with (although there’s a D).

We were very pleased with the hand gesture for opening. It's like Fonzi meets the Force.

One of the other thoughts we decided to discard was requiring that you close the door.  We thought perhaps that while the door was open the eye should be fully on.  You’d have to first close the door before you could start moving stuff.  However, once you closed the door you had 5 minutes (chosen based on one of the achievements) to solve the puzzle.  In the end we decided the puzzle was hard enough as is.

There was one other decision which seemed somewhat minor, but ended up, I think, becoming fundamental to the possible future of this game.  That is that originally before you could win the game by finding the safe behind the picture you had to clean the room of every stain.  However, due to the mechanism for moving some stains couldn’t be reached until you solved the puzzle with the Eye.  It doesn’t really line up with the motif, but it makes the business of finding the stains much more interesting.  It’s safe to clean them (after all that is your cover story) but to get to some stains you have to move furniture which sets off the alarm.  Silly, but effective.

Can't leave a spot untouched. Even if you risk the alarm to do it!

Well at some point, I thought that it didn’t make sense to have to find every stain because the main point was to get the treasure from the safe  (also I couldn’t find some of the spots that John put in and got annoyed and disabled the condition check so that I could test the win condition :).  We thought it would be a nice bonus to see who while finding the treasure could also clean the most spots.  However, after seeing the way people played, nobody really cared much about the treasure, they only cared about finding all the spots to clean and cleaning the room.  Our organizer said it was like “OCD”, he *had* to find all the spots.

After talking some, we thought really the whole concept of Extreme Maid Cleaning service was much more entertaining than just stealing while cleaning.  Forget the treasure altogether.  Instead you’re supposed to clean the place without setting off alarms or traps (we’d always pictured having traps at some point.. .like trying to break into the Pentagon, Mission Impossible style).  But what kind of insane place would require the maid service to work around traps?  Well a super villain hideout of course!  They need janitorial staff too don’t they?  They can’t really risk turning off all the alarms and traps just to clean things.  That’s exactly when that jerk James Bond would come in dressed like a maid and pretend to clean everything with all the traps disabled (perish the thought… someone pretending to be a maid).  So better for the super villain to be safe and leave the traps and alarms on, requiring the maid to have to work her way around them.

Who do you call when your average maid service just doesn’t cut it (and keeps getting killed by your Robot Sentry’s)?  You call Extreme Maid Services (or Ninja Maids… or … something)!

For the Win

No Comments

Hardpoints and Workflow

One of the interesting questions dealing with a full featured editor like Blender is how much really makes sense to do.  There’s a full game engine there, and so it’s possible to create an entire game within it.  But of course, given all I’m talking about is Unity then I don’t really want to make the full game in blender.

This came to mind recently because I was thinking about hard-points to place on the ships.  The idea is similar to that handled in Galactic Civilization 2.  Each component you add can be joined against a hard-point in the existing set.  You start with a chassis which has a certain number and then you add a wing

Galactive Civilizations 2:  Constructing space vehicles from hard points.

Constructing space vehicles from hard points.

which has it’s own hard-points.  The wing attaches to one, but contains many more itself.  This allows you to build very customizable ships, and I plan to use this concept to allow the players to build their ship for space combat.  Such a feature provides a number of great game benefits, like finding (in-game) particular or rare pieces (especially those that give certain abilities when attached to the ship) and allowing them to be specifically targeted, damaged and destroyed during combat.  But the basic point is that it allows individuality and customization.

So the question was:  Who is responsible for the hard-points?  Is it the artist who places them when he designs the chassis in order to place them in the most aesthetically pleasing way?  Or is it the game designer who needs to set them up based on number of properties necessary for game balance?  Most likely for game balance the designer would only need to specify the number of hard points to allow, but it’s also possible for perhaps physical reasons, and in my case that certain specialized hard points would be needed on top and bottom since they’d rarely be seen in this pseudo 2d game.

In some way’s the answer is both, but that’s not an answer easily addressable in Blender.  The easiest way I could imagine to do this would be to have the artist generate empties (which are objects that contain only one vertex).   The game designer could also modify these directly in the blend file, which would allow, for instance, the artist to place initial hard points where he likes them and the designer could delete or move them to fit some balance notion.

However, model files as they are treated in Unity are read only.  And when considering the work-flow of a designer doing a rapid test cycle within Unity, pulling up blender to modify the location of those hard points seems like more effort than necessary.  So the next direction to take is to use an element in Unity itself.

The good news is that Unity already has a visual editing capabilities similar to those in Blender which an artist would be familiar with using.  One of the things I’ve learned over the years of programming is that the shorter the test cycle is between making a change and trying out the effects of that change means the better you can work.  In Unity it is actually possible to modify within the editor while the game is running.   When I first started testing the physics restoration on the ships, I ran the editor and pulled them out of alignment using the model editing tools while the physics was running.  The physics  would then work to fix the alignment back to the 2d plane.  This was an amazingly tight loop to fudge numbers which are not based on any physical reality in the first place.

So there is one final decision which I haven’t nailed down a direction to take.  On the one hand, I might use Unity’s empties to attach to the object and position for hard points.  These would be children in the prefab, and I’d use the script to find them when it came time to attach parts.  However, the other option would be to store them as variables in scripts.  It turns out using the GUI extension scripting in Unity you can setup widgets to modify even variables graphically.  The easiest way to handle this is to add each variable to the script for each hard point.  The script would then be attached to the object and each of the hard points would have the small edit widgets to allow the artist to change them.  If the designer really does only need to worry about the number of hard points he can decide this by attaching the appropriate script and let the artist set the actual position for each.

In the next post on this topic, I’ll address the decisions made on which methods to take for implementing hard points and post links to the prototype in-game editor.

No Comments

Shootin’ Off the Design

One of the games I recently added on the Unity Games page is a remake of a not-quite game that John and I did a few years back.  I thought I’d take some time to explain the design ideas and delve into where I’m taking it.  Click the image below to play with it in the Unity Web Player.

Asteroid being destroyed

Asteroid being destroyed

Background

The idea originated with John (also on this site) and where it came from is probably best left to a post from him.  For several years we worked on Crystalspace.  When we decided to quit, Shooter (later to be named Longshot as you’d see in the web player) was our foray into designing our own game engine (also another story…)  At the same time I was working my way through a Masters degree and taking a course in machine learning.  At about that same time I agreed to develop the AI for the game.  I realized I didn’t really feel like generating a long tree of if-then rules and had just learned about behavior cloning in class.  So I pushed John into helping me round it out for the class.  We added another ship and spent some time with networking and left it there to see whether this behavior cloning thing would work… but this behavior cloning thing is also going to be another story. :)

Original Design

I’ve seen so many of these games now that it’s hard to decide if anything in particular was innovative about what we were doing.  Perhaps some of it was at the time.  It’s a top down space shooter that includes asteroids.  Much has been written on the rite of passage that is cloning asteroids… everyone should do it at least once.  Of course, we couldn’t seem to get the asteroids physics to work as well as we liked so we dropped them.  But really there’s nothing new there.  For the sake of curiosity, I’ve uploaded the windows installer for the original here.

Where there was a sense of newness was in the design of the engine itself.  This design, it turns out, is described pretty handily as “System of Systems”.  It is an idea employed by the military for many simulation games and uses High Level Architecture (HLA) as the formalism.  The idea there is that each of these systems is developed by separate entities, but they can be brought together and easily coupled into large, more complex systems.  Our thinking at the time wasn’t quite so complex.  I simply wanted to see whether or not we could thread one loop of physics at a reasonable simulation rate and thread another loop of graphics at a separate rate and yet another loop for gameplay without strongly coupling any of them.  My thought was that graphics could run just fine at 30 frames per second and the only reason to run it higher was because if it were strongly coupled with the physics you’d want that at a higher rate.   We did run the physics at a higher rate of 100 hz (along with the input so it felt responsive).  Interestingly the gameplay was entirely event driven responding only to collision events.  This is where Unity’s design is so nice because in the same way all of the gameplay exists now in the collision code.

function OnTriggerStay (other : Collider) {
if (other.name != "Bullets" && GetComponent(FireBullet).remoteFire) {
if (other.GetComponent(LifeCycle) != null) {
other.GetComponent(LifeCycle).hitpoints -= 1;
}
var closestPoint = other.ClosestPointOnBounds(transform.position);
var sparkPos = (other.rigidbody.position + closestPoint) / 2;
var spark = Instantiate (prefab, sparkPos, Quaternion.identity);
var sparkForce = transform.position - sparkPos;
spark.GetComponent(ParticleAnimator).force = sparkForce;
Destroy (spark.GetComponent(ParticleRenderer),0.5);
Destroy (spark.GetComponent(ParticleAnimator),0.5);
Destroy (spark.GetComponent(ParticleEmitter),0.5);
Destroy (spark,0.5);
}

It’s not entirely true that it’s all in that script, but that is a majority of it.  Two of my favorite results to come out of that design were the fact that the game ran with almost no CPU usage despite maintaining responsiveness and that I could lower the graphics to 8 fps and still play the game just fine.  It was painfully strobed, but it was possible to see what was going on.  Due to this it would have been easy to scale the graphics however necessary to fit into whatever capability the system had while allowing the physics to operate however needed.  However, this innovation wasn’t really much related to how the game played.

What may have been most interesting to me was the “hovercraft” design.  Although the motif is ships flying out in space, I thought it would be more interesting to see them rock as though on water.  We had already decided on forcing the 3d physics engine to fit to the 2d plane, but since we were using 3d models and a fully 3d engine, I thought we might as well show it off.  In order to do so we’d have the ship lean forward when moving forward and lean further forward when going really fast.  When stopping it would rear back (almost like a horse).  And best of all, when an explosion would go off it should rock the ship.  It wasn’t until using Unity’s Detontation engine that the rocking effect came into it’s own.  You can see this when you blow up an asteroid and get close.

The way this rocking effect was modeled was to virtually attach a spring to the front, back, and sides and have this pull the ship back into the plane.  Then we could apply forces from thrusters or explosions which would offset the springs and ultimately either pull or balance them out.

function FixedUpdate () {
if (rigidbody.position.y != 0) {
rigidbody.AddForce (0, rigidbody.position.y * -restore.y, 0);
}
yoff = transform.localRotation * Vector3(1, 0, 0);
xoff = transform.localRotation * Vector3(0, 1, 0);
rigidbody.AddRelativeTorque(xoff.y * -restore.x, -yoff.y * -restore.z, 0);
}

One of the really amusing side effects that came out of this was that by timing a forward and reverse thrust, one could cause the ship to rock to higher and higher degrees until ultimately flipping over.

New Design

Enter Unity.  For some reason Unity is designed with me in mind.  I don’t know who read my mind and made everything I could have possibly wanted out of a game editor, but someone did.  Thanks! :)  The result you see here was built in 2 weekends taking all the assets from the old project and porting all the code necessary (not very much) into javascript.  All told, I think  I spent about 20 hours on it and most of that was on learning how to do the networking (something I never did get right for internet latency on the old version).

Although I haven’t yet brought back the behavior cloning, even with a second ship the game was pretty boring.   But I really like the idea of modifying ships and customizing.  I’m not a very good artist, and I don’t feel like making hundreds of ship models.  So instead, I plan to make a bunch of ship pieces and allow the user to put them together into different pieces.  Of course some of the obvious choices would be chassis size and style, engine power, weapon type etc.  But one of the more fun ones due to this wobbly control scheme is to allow various levels of restoration power based on the types of items added to the ship.  If you don’t mind wobbling a great deal perhaps you can load your ship with more weapons.  Or perhaps you want a tight control and will exchange that for less fire power.  I’m giddy with the options :)

Another gameplay element I’m toying with is one that used to come up when playing Magic the Gathering.  When you’d duel another player you were supposed to put a card out on the line.   Whoever won would get the other player’s card (as well as their own back, of course).  Well I haven’t quite decided how players get cards (or really ship components) yet, but I thought it would make for an interesting gambit that when you do duel somebody you can take a component from their collection if you beat them.

More interesting however is to bring the behavior cloning back into it.  Because the idea behind BC is to create a model of how you play, one could imagine building a fleet of ships and playing with each in order to build up a clone which plays a particular way.  This allows one player to virtually control an entire armada when fighting another player, not just one ship.  But the downside is that if a ship gets captured that clone could be taken (or maybe just copied).  If you’ve made a particularly effective opponent someone may be able to steal that and use it in their own fleet.  Reminds me again of Magic the Gathering.  I used to play exclusively blue.  I don’t remember the names of the spells exactly, but I think they were “Steal Creature” and “Clone Creature”.  I remember playing one guy who was quite proud when he brought out some very rare, very powerful monster onto the playing field to take me out.  I had a steal creature sitting in my hand waiting for just that to happen.  On my next turn before he was able to attack, I stole it to use on my side.  And on the turn after that I cloned it.  Now instead of him having one very rare and powerful creature he had none.  I had two.  He was very, very angry.  I beat him quickly and left just as quickly :)

Anyway, hopefully people won’t be nearly as upset at losing a clone in the wages of war.  It is after all just a clone, but it creates some very frightening possibilities for components!   Keep an eye on this space, I’ll  talk more about advances in the game as well as give some background on behavior cloning and how to make it work.

No Comments