What's the best way to handle multiple weapons?

From the Asset Store
Be quick and choose the right answer for the shown equation.
  • I'm getting ready to start on my character animations. I've just been using placeholders for now while I worked on general gameplay mechanics and the HUD.

    The character is going to have 2 or 3 weapons, and I wanted there to be the ability to upgrade them visually (different color, appearance, whatever).

    This is an isometric game (like Baldur's Gate or Age of Empires II), so everything is sorted by a family with z-order sorting. This is what makes it tricky. If I just add in new animations, I don't have to worry about the z-order not working since I have already set the characters up. However, if I create a weapon as a separate sprite and then pin it or position it and have it trigger accordingly, I still need to make sure it sorts in the proper z-order.

    This picture of Golden Axe on the Genesis will give you an idea of the types of animations I have.

    There will be forwards and backwards walking animations. There will be an attack animation. And probably an idle animation of some sort.

    Now, normally when pinning a weapon sprite, it would probably be on the handle of the weapon and pinned to the character's hand. However, this would put it higher on the z-order sorting since the "lower" object is put in front. The character's origin is at his feet, and the weapon origin point would be up at his hand.

    The z-order would have to stay consistent when he is walking or when other characters get in front of him. I tried making the weapon sprite box the same size as the character, but it starts to get a bit confusing as to where to put the origin point and making sure it stays consistent with the character's animations, so I don't know if that's optimal.

    Now, I can avoid this by simply making new animations for the character with each new weapon, but this will start to add up quickly. I could also make the weapon invisible during the walk animation and have a few less animations to worry about, though it would look a bit silly it would still work.

    Anyway, I'm trying to figure out the best approach.

  • Well, I guess I'll have to do without visual upgrades to weapons. Maybe I'll either make upgrades just stat based or maybe I'll make a few worthwhile upgrades and keep the number low.

    Since I haven't heard from anyone, I'm guessing that this issue is difficult to solve. Like I said, the main problem was maintaining z-order sorting in an isometric game. Since the sorting is based off the Y value which is tied to the image point I believe, then weapons will always be a little off since they need to be placed high on the character.

  • I'm going to be attempting something similar with my game. In yours are the character animations more or less going to be the same regardless of the weapon he's wielding?

    If that's the case, perhaps you should make all weapons (or at least a group) one sprite with all the animations for the all the weapons. You could have an array with an X/width that sorts types (sword, spear, etc) and a Y/height that lists specific animations ("swing1IronSword", "stab1IronSword", etc)

    Then you'd use that array to set the animation for the sword sprite the character is holding, like Set Animation Sword swordAnimations.At(weaponType,weaponNum)

  • PigFiend Yeah, I had one test sprite set up to hold the weapon animations, but I started running into trouble with getting the game to sort the z-order correctly. All the characters are sorted based on their Y value, and their origin point is right at their feet. The lower characters on screen are moved to the front. So if the weapon has a higher Y value, it is moved towards the back when it should be in front of the character. Of course, it also needs to be behind any characters that walk in front of this character.

    Ideally, I would have placed the weapon sprite's origin at where it would hit the hand of the character, but that won't give me the correct z-order sorting. I could make the hitbox for the weapon bigger, and place the origin below the character so it's in front. But then, doing that makes it hard to get it lined up properly and at the same time make sure the weapon appears behind anyone walking in front.

    And yeah, there will be different animations depending on if it's a dagger, bow, sword, whatever. So, I have to do this for each type.

    Remember this is an isometric game, so characters will be moving up and down the screen as well as overlapping. This is where the trouble lies.

    It just seems not worth the trouble. I could make separate animations and the sorting would be fine since I would be using the character's origin point for the sorting, and I already have it working properly, but I would not feel like coding in dozens of animations for each hero.

  • Hm. Well, good luck! That's my favourite style of classic video game.

  • you could just use one sprite for the weapons, while creating it, make sure the sprite is the same size as the player sprite and has the same origin point..

    After the weapon-animations are made you can crop the images, the origin point will stay where it is, so your z-order problem wont exist..

    Yep.. the origin point of a sprite can be outside of the image..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • LittleStain Hmm, that's an interesting idea. I'll play with it when I get a chance.

  • I know this is a very old thread but what did you find was the best way?

    I was just thinking about this and was considering animating the whole arm for each weapon and attaching a the shoulder.

    For the z-index part of the question couldn't you set the arm/weapon equal to z-index of the character's sprite?

  • Well, I ended up just rendering animations for the character with both weapons since I only used a dagger and a bow. Then, I just set it to the correct animation depending on a condition or variable, whatever.

    Working with multiple weapons in an isometric perspective like Baldur's Gate can get tricky because there are so many different angles needed for each animation.

    Depending on how many angles you need for your game, you can more easily get away with just rendering the weapon/arm separately and attaching it later. You'd just need to make sure it lines up correctly no matter how the character is facing.

    I mean, there are multiple ways to do it. You'd just have to check performance or memory use and see what you can get away with.

    You can click the link in my sig and watch my videos if you want to know more about it. Check the video called "gameplay commentary" for a closer look at my finished animations while I was still using Construct 2.

    All of this is a bit irrelevant for me now. I moved my project to Unity and can simply show or hide weapons as needed since it's 3d. There's no longer a need to pre-render my animations.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)