Forum rules - please read before posting.

Sprites Unity Complex using Animation 2d bones

I'm trying to use bones based animation for my characters. I read on the form that using Sprite Unity Complex is the preferred method while working with bones, but I'm not sure about one particular issue. My characters can move in 6 directions (R, L, UR, UL, DR, DL), so I need to create 6 (or 3, if I can flip them) different skeletons and 6 different set of sprites.

The question is: can I manage the 6 directions with 6 different PSB files, or am I forced to place all 6 in the same PSB and turn on/off sprites and bones via animations? Is there a "proper" way to go about this? I'm afraid that having all 6 directions in the same file will be a pain to rig and animate, since layers hierarchy is always flattened when importing in unity.

I found this thread on the same topic but it's not clear to me if the OP needed multiple directions (beside R and L) like I do, or not.

thanks!

Comments

  • A script that provides the ability to use frame-flipping with Sprites Unity Complex characters can be found here:

    https://adventure-creator.fandom.com/wiki/Frame-flipping_for_Sprites_Unity_Complex_characters

    You don't need to have each direction's graphics be a separate file - Unity will source the sprites from whichever files they're in, which can be shared or separate.

    When it comes to the rigging, there's a couple of approaches you can take. It's not so much a case of which one is "best" in the general sense, but more about which one is right for you and your situation:

    1. Use a separate rig for each direction, and enable/disable them as necessary.

    This approach will make your Hierarchy a bit more cluttered, but is generally a bit easier to work with. For a given rig, each bone will generally be associated with a specific sprite the whole time - so you can concentrate on just working on animating the bone rotations without dealing with sprite-swapping as well.

    1. Use the same rig for all directions.

    This is harder to set up, but will be the more efficient approach on a technical level. For each direction, you'd need to animate each bone's associated sprite as well as their rotation (so e.g. the Head bone's sprite is showing Head_R when moving right, Head_DR when moving down-right etc). The sprite-swapping could feasibly be done on another layer in the Animator, to avoid having to update them as part of the standard idle/walk etc animations.

    This is also the approach that Broken Age took, though that involved creating rigs in separate 3D software rather than animating them inside the engine.

  • Hi Chris,
    thanks for the answer. I was actually thinking about implementing solution 1. By playing around with Sprite Complex Brain I think I'm getting an idea of how I could structure the character in order to work with bones without creating a mess.

    I still have few issue though, and it seems I'm blocked:

    1) I tried following Brain's example and use the angle parameter in a blend tree to determine the right rig to show. No matter how I divide the angles, it always seems that at least two rigs get activated at any time, instead of just one. No idea if it's an issue of the blend tree states overlapping, or the way I hide/show the rigs in the animation

    2) The sprites order of the PSB get always messed up during animations (even in preview). I tried even excluding "follow sorting map" but it doesn't seem to have any effect. I can't imagine where the issue lies

    If it's useful, I uploaded the prefab + assets for the character I'm trying to build. The model and animations are super crude but they're just to give an idea

    https://www.dropbox.com/s/z319kk6tl4xi6pm/test-character.zip?dl=0

    any feedback is welcome
    thanks again

  • The package is missing the nested prefabs that hold the bones, but if you're having issues with the Blend Tree and angle parameter, try using the Direction integer and transitions instead. A Blend Tree is designed for properties that can blend between values, rather than just either on/off.

    Though, it would also be possible to set the rig enabled states solely through code based on the angle, which can be read from the character's GetSpriteAngle function.

    As for sorting issues, with updates to Unity's sprite system it's no longer necessary to rely on AC's Sorting Map for 2D sorting - you can just use it for character scaling. You can attach a Sorting Group to the character's root to have each sprite's Sorting Order be relative to one another, without affecting the overall Sorting Order relative to other objects in the scene. The new 2D Primer covers how to prevent the Sorting Map from affecting sorting orders here.

  • edited August 2022

    Hi Chris,
    I solved the sprites overlapping in the wrong order by removing and re-including them in the scene. No idea what happened to mess them up, but apparently it wasn't related to the sorting map.

    For the animations, I followed your suggestion and tried to implement everything just with transitions. I made 2 layers in my animator: one that listens to the Directions and uses 6 animations that just turn off/on the correct rig; and another layer that listens to Speed to manage the idle/walk/run animations. It works ok, the only doubt I have is that I had to "merge" all animations of the same type in a single one. So for example I don't have anymore idle_L, idle_UL, idle_DL etc, but I have just a "idle" that animates all the bones in all the rigs. This makes managing the animation window a bit of a pain because of the amount of bones (I can turn off the rigs from the inspector window to hide them from the scene, but the animated properties in the animation window will still clutter everything), but I can live with that. Do you think this a sensible/scalable solution for a rigged character?

    I still have a small problem that might be related to AC: when the character talks, the subtitles appear above their feet instead of above their head. I think this is because the character doesn't have a sprite renderer: in fact, the only way around this that I found is to add a sprite renderer and attach an image of roughly the same size of the character, and turn its transparency up to hide it. It feels hacky, so if there's another way to fix it please advise. This is the structure of my character object so far (few directions still to do)

    thanks!

  • Do you think this a sensible/scalable solution for a rigged character?

    It does look troublesome to deal with like that. This would be more feasible were you using sprite-based animations, but if each direction uses a separate rig it is going to get messy quickly.

    I'd personally probably look into the single-rig approach, but going back to the separate rig/animation approach, I'd say it'd be worth looking into moving each of your idle/walk animations to direction-specific layers, each with their own Idle -> Walk transition. Your "BodyDirection" layer could probably be moved to the base layer, effectively flipping the ordering.

    the subtitles appear above their feet instead of above their head. I think this is because the character doesn't have a sprite renderer

    That's right - AC will try to use a Sprite Renderer to "guess" where that character's subtitles should appear. If it can't find this component, or you want it moved, you can correct this by positioning a child object in the character's Hierarchy and assigning it in their "Speech menu placement child" field.

  • worth looking into moving each of your idle/walk animations to direction-specific layers, each with their own Idle -> Walk transition

    I'll look into that. I guess that ultimately it's a choice between having clean animations with cluttered animator controls, or cluttered animations with clean animator controls

    The speech placement did the trick. Thanks for all the advice!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.