14
\$\begingroup\$

I want to create a 2D game but I'd like to have the character to wear tons of different equipments on different combinations, like a RPG or something.

So let's say the user changes his/her shoulders and pants, this must be shown to the player and all these different equipments must follow the different characters action (hitting, being hit, spelling magic, etc.).

I see a few problems that I'd like to know the best approach/algorithm/architecture to solve.

1 - Sprites or Animations

Should I create different sprites for each equipment in each action animation?

Is it better to just have the equipment sprite and animate it directly on code like rotating and translating (using something like tween on Flash)?

Is there any other better option? (I really don't like the ideas above)

2 - Positions

Let's say during one of the character's move he starts looking directly in front to the player's view but ends his movement showing his right side to the player (like if he swings his sword from one side to the other).

If we consider one part of the user, like his head for example, it starts in front and then turns left.

It means at least 3 different positions for each head equipment (helmet, cap, whatever).

This surely influence the answer of #1 question. How is the best way to achieve that?

3 - Layers

Let's consider a character move where he spins 360 degrees with his arms open. At the beginning of the animation, his right hand is close to the user's view and then, at the middle of the movement, this is probably behind the character's body on the animation.

Whatever is the option on #1 question, you surely needs to use some kind of layer model to make this sprite or animation to starts closer to the player's view and later change to far away from player's view.

Is there any good way to do that?

I know the question is quite long and difficult to understand. Let me know if you think it's better to have some drawings to try to explain which one and I'll try to do that.

\$\endgroup\$
2
  • \$\begingroup\$ To what level do you intend for your art to be at? Like retro pixel art? Or those HD sprites, if you have any existing art that would really help me tailor my response. \$\endgroup\$ Jul 23, 2010 at 5:25
  • \$\begingroup\$ Hi Noctrine. Actually I'm considering it as a "art independent" question. I'll try to draw some explanations later this weekend to make it easier to understand. Thank you \$\endgroup\$ Jul 23, 2010 at 12:45

5 Answers 5

8
\$\begingroup\$

I think it sounds like you are looking for a 2D skeletal animation system perhaps? I don't know of any off-the-shelf systems for that unfortunately, since it has been mostly superseded by the 3D-gfx-but-2D-game trend.

\$\endgroup\$
7
  • \$\begingroup\$ +1 It's much easier to do this if you just make the character 3D. \$\endgroup\$
    – knight666
    Jul 23, 2010 at 10:10
  • \$\begingroup\$ but for "3D-gfx-but-2D-game" I would have to consider one of the solutions I mention anyway otherwise I'll need to have a sprite for any items combinations, for example, the same chest piece with 10 different braces pieces will generate 10 animations :( \$\endgroup\$ Jul 23, 2010 at 12:49
  • \$\begingroup\$ Not really, you just have attachment points on the skeleton and can drop in whatever you need. \$\endgroup\$
    – coderanger
    Jul 23, 2010 at 16:50
  • 2
    \$\begingroup\$ I've made an (open source) simple 2d skeletal animation library for XNA, including a decent editor. Check out youtube.com/user/srekel#p/a/u/0/46LIoFNdG_4 and youtube.com/user/srekel#p/a/u/1/8sYkeu5k7XE \$\endgroup\$
    – Srekel
    Jul 23, 2010 at 20:02
  • \$\begingroup\$ This is almost the correct answer. Actually you made me figure out that what I'm looking for is 3D Skeletal system for 2D animation. I need to find algorithms for that (if exists any) \$\endgroup\$ Jul 24, 2010 at 17:21
8
\$\begingroup\$

As Zorba says, most retro games didn't do this specifically because you would need (with sprites) to have multi-frame animations for every single piece of equipment.

Some "lazy" alternatives:

  • Palette-swap the gear instead of making totally different sprites.
  • Draw the character in such a way that the only parts of their body that animate are parts that aren't attached to gear. Like, if the character can only wear a single suit of armor anyway, make it a Helmet instead, and then you're free to animate the entire body while keeping the head still.
  • Use a single sprite for the character in the main game screen, but show the equipment in a subscreen with a static portrait. Then you don't have to worry about animation.
\$\endgroup\$
2
\$\begingroup\$

In old games like the Ultima series, they would indeed draw one piece of equipment in every possible character pose. Occlusion would be dealt with either by not drawing the gear (if the left glove is behind the player sprite you don't need to worry about it) or by just drawing the gear in back-to-front order.

Obviously this was very labor-intensive, and as a result there were relatively few pieces of unique gear, with a lot of palette-swapped and palette-modified versions of that gear.

In a modern game, I'd strongly recommend making 3d characters. If you want 2d-looking art or your platform doesn't have the horsepower for actual 3d, you're still likely to be better off modeling everything in 3d, rendering, and then tweaking the final result by hand.

Alternatively, if you decide you don't need tweaking, don't have horsepower for full 3d, but don't want to ship a huge sprite library, you can package the 3d models and render them to a texture in realtime when you know the model is about to show up in-game.

\$\endgroup\$
2
  • \$\begingroup\$ The same I mention on the other answer is considerable here: I would have to consider one of the solutions I mention anyway otherwise I'll need to have a sprite for any items combinations, for example, the same chest piece with 10 different braces pieces will generate 10 animations :( \$\endgroup\$ Jul 23, 2010 at 12:50
  • 2
    \$\begingroup\$ You'd composite the "end sprite" at runtime. You don't have a sprite for "the player", you'd have a list of sprites that are rendered for each animation frame. So if the player is facing to the right, you'd render "left glove", "left bracer", "player character", "boots", "pants", "body armor", "helm", "right bracer", "right glove" in order. Then you animate each piece of gear independently, floating in midair. \$\endgroup\$
    – ZorbaTHut
    Jul 23, 2010 at 19:03
1
\$\begingroup\$

Check James Da Silva's book where he explains how he did The Dishwasher: Dead Samurai. It'll show you how KISS pretty much can solve this. The suggestion of using 3d or 2d skeletal animations are valid, and kinda in the same realm.

\$\endgroup\$
2
0
\$\begingroup\$

This is a great question but I think you've answered it yourself - you need a 2D bones system that supports bones changing layers, so different limbs can go behind and in front of each other as the character rotates. You will also need to draw your sprites from 4 or 8 angles (or however many you need). Depending on what skills are in your team it might be easier to create these assets in 3D and render them out from the angles you need.

Using a 3D engine is also a good solution, although this will bring it's own set of challenges.

\$\endgroup\$
1
  • \$\begingroup\$ Yeah, that's almost that. Just got the other answer as correct but this one is valid too. As i commented on the other, I need a 3D skeletal system for 2D animation :) \$\endgroup\$ Jul 24, 2010 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .