Wednesday, February 4, 2015

Humanoid Mecanim Overview

As I've stated previously, I'm trying to make a 3D fighting -- think Tekken, Street Fighter, Dead or Alive, etc. -- and want to use Unity3D as my engine.  Though I know there are already some tools --  both in and out of Unity -- to solve some common problems, I really want to try and solve as many as I can myself.
One problem I can't solve though is I can't make every character myself from scratch.  Fortunately, there are plenty of tools and character generators out there to help with this.  My goal is to find a character generator that is fast and relatively cheap that generates characters that are already rigged / skinned.

Fuse from Mixamo and available on Steam.

Fuse is a character generator that works directly with Mixamo, an online animation and auto rigging service.  Fuse is highly customizable, and -- in my opinion anyway -- the characters look nice.  It also utilizes Substances, a special type of material developed by Allegorithmic in use with their tools such as Substance Designer, which adds a high level of customization in various materials.
Unfortunately, looking nice comes with a price as I find many of them are rather high poly or at least not optimized for mobile.  Also, auto-rigging requires Mixamo.  Fortunately, Mixamo does allow users to auto-rig two characters, Fuse or otherwise, for free during a period.  Without an account though, which is about $50 a month -- a little hefty in my opinion, especially when prototyping -- you can't get any facial rigging.


MakeHuman is another option I looked into and was extremely excited about for awhile.  It's free and the characters are highly customizable.  One issue though is that the characters aren't the prettiest.  Also, and every character generator I've used is guilty of this, the teeth are extremely high poly and not optimized.  The characters do come auto-rigged, which is very nice; sadly, the skinning on said rigs isn't really the best, especially when it comes to certain areas such as the neck.  Also, the rig I was using had additional bones that conflicted with Unity's Mecanim system, which I will go into later.

Daz Studio

Daz Studio is a program that specializes in making characters and posing them.  Daz seemed like a great option as it was very similar to MakeHuman.  It even had the ability to export morph targets for facial expressions.  The characters look nice but they do have the recognizable look that most people find off putting.  It did have some problems though:  not optimized characters, full body morph targets, a rig that won't play nice with Unity's Mecanim system.

Autodesk Character Generator


Finally, Autodesk, the company behind 3D Studio Max, the 3D suite I use for my models currently.  Autodesk Character Generator's level of customization is interesting.  You don't use a slider to adjust features such as making the nose bigger or the ears smaller.  You select from a set of body types and then interpolate between two of them.  It's not as customizable as I'd like with things like Fuse or MakeHuman, but you definitely get a wide variety of characters.
Where it has advantages is how it can be exported.  You can select from different mesh resolutions and different mesh sizes as well as facial rigging -- both morph targets and bones.  Now, similar to Mixamo, this isn't for free, but it is much cheaper.  Well it's technically free.  If you want want the low resolution and don't mind having no facial rigging, it's free.  If you want the additional features, however, it's $50 dollars a year, plus each character that uses extra features is $5 (or 5 cloud credits, which you can only buy in sets of 100, but you get 50 once you pay the initial $50 for the subscription).
Anyway, so far, ACG is my preferred choice.  Maybe once I feel more confident in the project, I'll go with Fuse or a different character editor.  The nice thing is that because rigs are already autorigged, I can use 3DS's Skin Wrap tool to transfer skin weights, and because of Mecanim and humanoid rigs in Unity, I should be able to retarget animations that I make.

Mecanim and Humanoid Rigs

So with a recent version of Unity, 4.3 I believe, a major change to the animation system, a system that initially I was rather fond of, was introduced.  I was initially bummed out, the seemingly overcomplicated web of states seemed like a huge hassle to learn.
As I started to experiment with and learn it though, I started to realize it's pretty cool.  It's nice to be able to setup states and see how they will translate and connect.  It's not a perfect system, and I still have some reservations, but one aspect of it that I feel like will be necessary to even get close to finishing the 3D fighter I have envisioned is humanoid rigs.  Humanoid rigs are not as simple as "import your model and it works!"  Well they are to a degree, but there is some finessing and careful considerations that have to be made when making one of these rigs.  A developer at Unity wrote a very useful post about Unity's Mecanim tools here --  .  I'm basing a lot of my information based off of this and will refer to it.

Ideal Rig

The ideal humanoid rig has two spine bones, one for the spine and one for the chest.  This is a problem is that many character generators export rigs that have three or more spines bones.  The closest is Autodesk's Character Generator which gives you a script to convert the export rig to a biped, but it moves the first spine near the pelvis so it's semi-accurate.
This rig, generated by ACG specifically for Unity, has through bones.  The gray bone above the spine is a through bone; it will not be animated.

When assigning the hip, spine, and chest bone in Unity, the spine bones not used are referred to as through bones and even if you animate them in your 3D suite, their animation will not be reflected in game.  This sounds rather irritating, but from what I've noticed is that you don't really notice too much.  A good way to test this is when setting up the avatar rig, go to the muscle view and just play with the different distortions and assign the spines differently.  I find, by default, Unity does a pretty good job assigning the skeleton by default, but rearranging it can help.
This muscle test shows how the character moves without the gray bone in the previous image without movement.

Again, the reason for doing all this is to save time through retargeting animations, so I don't have to animate the same animations for every character in the game, but use the same humanoid animation across all characters.


Another important aspect is for mirroring animations.  In some games such as Virtua Fighter and Dead or Alive, character animations "mirror" -- they switch between left and right bones as illustrated in the video below.

Interestingly, Tekken doesn't mirror.  I think I know why though.  Since the game is very left and right oriented -- left punch, right punch, etc. -- that if you mirror, things will become confusing for attacks.  Since I want my game to be simple input-wise -- just punch and kick for attacks -- I think mirroring, which allows some attacks to end shorter and flow more fluidly.
My mirroring system is a little strange though and I'm not sure if it's the best way.  Essentially, I have two float parameters in my Animator -- MainMirror and SubMirror.  The idea is that idle, walking, etc., uses MainMirror and SubMirror is equal to this most of the time.  Then, attack animations, which also use a blend tree for mirroring but based off SubMirror, use an AnimationEvent to change MainMirror so that when the attack animation ends, it will transition to the proper mirrored animation.  There's some complex setup with this, but I think it solves what I'm trying to do.
An example of character mirroring in Unity

Root Motion Issues

 Another challenging part of animating humanoid rigs involves root motions.  Root motion is the concept in which the animation of the root in the modeling suite will move the character as opposed to animating the character in place and moving them in code.  For a fighting game, I think animating the movement in very important; however, when using humanoid rigs, Unity assumes a lot of the movement.  Body orientation in the import settings can cause a lot of movement issues so if you want the character to run forward, it may not be in a perfectly straight line, which can be rather problematic.  I may be messing something up with this; using the biped as an animation base could be causing issues so I just need to investigate this a bit more to figure out how I can make things more stable.  Or, if worse comes to worse, just animate the character through script for certain movements.

The character is supposed to be walking straight but they go off into the X a little bit after a few playthroughs.

Don't Worry -- Silly Happens

In my opinion, you shouldn't be concerned with making EVERY in game animation beautiful and perfect.  I was experimenting in various games and there are plenty of goofy things.  Tapping blocking in Virtua Fighter or the wave dash movement expert players in Tekken utilize.  I'm not saying the animations can be garbage, but if you're going to stress over some strangeness in animation during transitions, the game will never get done.

Other News

 In other news, Battle High just earned a rather positive review from What's Your Tag.  Also, I wrote a guest blog post for OUYA.  I'm going to be starting some new Battle High 2 work soon, which should be interesting.

Sunday, February 1, 2015

Global Game Jam 2015

So I participated in the Global Game Jam again this year.  The game my team and I developed is entitled Escape from Death Island.

One of two giant duck battles

It's a simple game in which you lead a mob of castaways away from danger.  It's definitely silly and a little more than just imbalanced.

This was the first year though that I just didn't have a good time.  I wouldn't say I had a bad time; a bad time would have involved fights and everyone leaving, angry at one another, and that didn't happen.  I think the feeling I left with though after this Global Game Jam was simply, "I would have rather just stayed home."

I found this image while searching "stay home", but also, is that neck pillow Photoshopped?

I do realize the entire setup of the Global Game Jam sort of annoys me and possibly how the Pittsburgh chapter of the IGDA runs it.  First off, the keynotes just weren't overly inspiring.  Only the first one really felt like it had anything to do with game jams, applauding jammers for just showing up.  The second was just sort of another call for diversity in character design, which is great and is something I support, but to inspire for a game jam, where a good portion of games are prototypes and don't have representation of human characters at all, it missed the mark.  The third one was just madness, a board game designer trapped in a CG card tunnel telling us about his projects in which "the magic" happened but nothing about game jams really.

Then the theme was announced.  I'll be honest, the themes over the past couple of years for the Global Game Jam have irritated me leaving me rather uninspired.  Another part of me is even like, "Why have a theme at all?"  I think a theme helps give focus, but sometimes I think a theme can unintentionally deflate inspiration, which I think this year's theme, "What do we do now?" sort of did that.  Also the delivery method was rather eye-roll-inducing.  In an event in which time management is important, I felt both this and keynotes were a waste of time.

I've sat through uninspiring keynotes and deflating themes before and have had great times at the Global Game Jam, so why was this one different?  Why did I have a bad time?  One of my friends even drove from Maryland to visit and participate, and I felt bad that I was grumpy and just not having a good time.
Well, one easy excuse was I was exhausted before the jam, an already exhausting event, began.   I had been playing The Evil Within the night prior and stayed up till 3 AM thinking, "Oh, this will just prepare me for the jam", which was a huge mistake and honestly could have been the main reason I was cranky.  I was just tired and would have rather been sleeping I think.

I blame you, Sebastian!  Why the hell do you have to die so easily?!

Though I learned some new concepts making Escape from Death Island, I had been working with Mecanim and human animations recently, so during the game jam, I was wishing I could have just continued working on that.  I think that feeling of "I'd rather be doing something else," is a major set back when doing a game jam.  I think if I had set the goal of "I really wanna make a game that utilizes this," it may have been more inspiring for me.
Anyway, I was left contemplating a lot of things.  Do I like game jams anymore?  Do I like game development anymore?  Am I too old for this?  While asking these questions, I stumbled upon a Global Game Jam retrospective on Gamasutra by Guilherme Costa.  What I liked in particular is that they listed 10 items to keep in mind when participating in the Global Game Jam, and as I read the list, I think some of these and the fact I didn't really adhere to some could explain why.  So here is that list and whether or not I felt my team did a good job on them or not:

1 - Minimize the team the most possible, short prototypes are produced faster with the smaller number of people. The lower the number of people in a group, the lower the possibility of a conflict as the activities to be performed.

I think we did this well.  We stayed with the same 3-person team we usually do, but even with the low number, I do think there was some conflict, which I'll go into later.

2 - If using any development tool (Unity3D, GameMaker, Construct etc.), avoid using add ons or frameworks. Can be great in the daily development, but if someone from the development team did not know, the project will not progress.

We used Unity3D, but one issue was that Unity now has so many add ons in itself that it can be challenging for someone who doesn't have a lot of experience with it or at least slow down progress a bit when trying to use some of these new features such as the UI system, which I'm not even too keen on yet.

3 - If you are responsible for the design, is incisive as to what's planned. If someone disagrees, prove that this design is really the best choice. If still the problem persists cut the people in the group or leave the group as soon as possible. It seems extreme, but it is best to keep everyone on the team happy with what they do than working in an uninteresting design.

This one is a bit major.  I think a problem we had early on is that I wasn't feeling the design we were going for or some of its features.  Then again, maybe I just didn't like them cause I was tiredI think the issue I had is I knew some features weren't important and trying to do them would slow down and split focus.

4 - Game design should occupy 10% of the total jam time. Remember that time still passes as you eat, sleep and meet other people.

 I think we did this one well; we chose an idea and ran with it rather quickly, but I think one issue that we didn't do is "meet other people."  We usually leave the jam site, this time the Art Institute of Pittsburgh, which creates some bittersweet feelings to begin with, so we didn't meet anyone, we didn't even playtest our game.  It's funny because in previous jams we've done this and it's never been a problem, but since I was feeling a bit deflated already, maybe some of the energy from other jammers might have helped motivate me.  Also we went back to my employer's office to work, which made the game jam feel like work.  At the time I thought this would be a great idea, but game jams are hard work and being there made it feel like work and not something I was doing for fun.

5 - Games made in game jams are prototypes. Focus only what is really important. Animations, camera effects, lights and shadows, do not affect gameplay, do not invest.

I feel like this is something we fail on every game jam.  We focus on things that are not important -- often when I know it's an issue and am ignored about it -- and the core of the game ends up suffering.

6 - Avoid that someone in the group runs out of tasks. Running out tasks drops the morale of any participant.

 I don't think this happens to us really; the opposite happens were we end up having too much.

7 - Create integration cycles. Avoid integrating all just at the end, integrate everything that is done in cycles of 1 or 2 hours, every two or three cycles, gather the team and make a debate on what has been done and will be done. The lack of continuous integration was the biggest problem of my team in this issue.

This is a good one.  I don't think we messed it up, but having specified cycles for it would help organize time a bit better.

8 - Try to create pause cycles for the group. Stay awake and well fed is always important, but even more important that everyone is the same way during periods of development.

We've never really had an issue with this.  We used to stay up all night, but now we make it a priority to get sleep.  I think my problem is I didn't get enough sleep due to my idiotic 3 AM bedtime the night prior to the jam.

9 - End the project a few hours before final delivery, do let other people play and try to find errors.

 This one irked me because we didn't start the jam until about 7:30 PM on Friday due to the keynotes and other things, but PIGDA wanted the games done by 3:30 pm on Sunday, which made the jam not really feel like a 48 hour game jam.  I think if he had planned that it was really only a 24 hour game jam, I think we didn't budget our time well for this delivery time because we assumed it'd be at a different time.

10 - If everything went wrong, do not worry, failing will not kill you. As time passes, the frustration becomes a thing of the past. Lift, organize thoughts and come back to fight.

I think the problem I had with this one is I sort of did feel bad about failing since we had never done it before.  Though I was so exhausted on Sunday, we did submit our game to the Global Game Jam site, but we didn't go to the closing ceremonies.  I just didn't care, which felt so rude and defeating of a game jam's purpose, but again, I was just exhausted.

Again, I sort of was wondering what else I could have done differently and one thought sort of scared me.  I had done Ludum Dare last year, which was a solo game jam and enjoyed that.  The fact that it was a solo game jam started to make me think:  "Am I just that bad a collaboration now?"  It was funny because the first keynote was given by a solo indie, and though she mentions that she's not really solo because she has friends, families, and contractors that help her in various ways, I wonder if she finds a certain freedom in it.  I can see some advantages.  You don't have to have meeting upon meeting to sell an idea and make sure everyone believes in it or is okay with it.  You don't have to worry about compromising an idea to the point where you don't even like it anymore.

"Johnson!  This is the 16th meeting, and you are now the only one who doesn't believe in the the combat system! WHY?!"

What worries me is that even the prior two assumptions I'm making feel rather selfish.  It's my idea, and I want it a certain way!  or worse, This isn't my idea, so I hate it already.  I'm sure there are designers -- of any field, famous or otherwise -- who think like that, but they are probably terrible to work with or at least if you are someone who doesn't believe in the idea.  Anyway, as I continue to develop and design, especially on side projects, I think collaboration is something I really need to work on.  I think this Global Game Jam was a failure; though we finished a product, I left it, not with a feeling of regret, but with this gloomy dissatisfaction that hopefully I can shake by the next game jam I do.

If I do the Global Game Jam next year, I think some of the following could help:
  • Go in with a goal.  Do I want to learn UI?  Do I want to practice an animation system or a certain mechanic?  Whatever I'm trying to do, pick something and focus on that and tie the theme into it.  Don't tie it into the theme
  • Stay at the jam site or at least don't go back to your office of employment.  I think staying at the jam site would have maybe given me some inspiration or allowed for playtesting or something that would have motivated me.
  • Be more assertive if you don't like something.  I think I took too far of a backseat and ended up working on something I just wasn't in love with.
  • SLEEP!!!!  Sleep the night before, sleep during, just be rested!!!  Again, all of the negativity I felt could have possibly been avoided if I were rested.
I can't guarantee these would help, but I think they'd be a good start.