Forum rules - please read before posting.

Animation Layers

I'm looking for some technical advise. I'm making my first adventure game(2D).
I have a player walking about the first scene, he is animated in 4 directions. The characters first task
is to put a T-shirt on. I have the T-shirt animated so it can be on the character and follow the characters
walk animation.

So can i have the T-shirt animation invisible, then enable it when he picks up the T-shirt?
Or is there a better way?

Thanks

Comments

  • Are you trying to enable a separate T-shirt sprite that appears over the player?  If you're changing the character's clothes, the usual way is to create a new set of idle/walk/talk animations that have him wearing the new clothes, and replace them during gameplay.  You can do this with the Character: Animate Action and changing the Method to Set Standard.
  • Thanks for the reply Chris. Yes thats exactly what i'm hoping for.

    The character has 4 items of clothes, which can be found in any order. So i was trying to avoid a
    silly amount of combinations(16), hence i thought i could have the character wear all the clothing layers, but have them invisible till pick-up.

    It was a clever solution to save me doing loads of frames.




  • Hey Chris, your solution is great, but do you think the layers method can work?
  • Yes, but you'd want to switch to Sprites Unity Complex as your animation engine (see 3.9 of the Manual).  This allows you to control which 2D animations are played based on regular Mecanim parameters, rather than have AC look for the relevent one by name.

    Once you have your idle/walk/talk etc animations wired up again using this method, you can then have the clothing as an additional mecanim layer, and have another parameter control which animation is played.  You can then control this parameter using the Character: Animate Action.
  • Thanks Chris, i'll give this a go. Sounds like it could be useful later in the development too.
  • Ok, this is really frustrating. Unity can't display two spites in one sprite renderer. So you have to use
    another sprite renderer for your second layer. This causes another problem, the direction and speed parameter isn't passed onto this second sprite, so you can't animate your second sprite to match the first. I'm sure there is a work around, but this was to save me time, it hasn't.

    I just need to get the 0,1,2,3(direction) + Speed data, to my new sprite and i'm fixed.

    Any ideas?
  • Ok, something is wrong here. I put the Animator on the child of the player object, i then put the sprite renderer(s) on the children of that. This seems to be passing the direction/speed data i need. But now when i try to drag stills onto the animation time line i get. 

    /Users/builduser/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs:721)
    UnityEditorInternal.DopeSheetEditor:CreateNewPptrDopeline(Type) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs:683)
    UnityEditorInternal.DopeSheetEditor:HandleDragAndDropToEmptyArea() (at /Users/builduser
    /buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs:624)
    UnityEditorInternal.DopeSheetEditor:OnGUI(Rect, Vector2) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs:105)
    UnityEditor.DockArea:OnGUI()


    It looks like you must have a Sprite Renderer with an Animator, so you basically can't do layers without scripting.
    Monophonic.
  • This is to do with Unity, rather than AC, but it certainly is possible to have multiple sprites on a character animate together - and people have been doing this in other games.

    Place a single Animator component on your sprite child, which should also have a "base" sprite such as the torso (or could just be an empty SpriteRenderer component).  Then add any other sprite "layers" you need as child objects of that.  Your Animator will then be able to control the child sprites as well as the one that's placed on the sprite child - the only thing an Animator can't do is control objects higher up in its hierarchy.  Any parameters in this Animator will be accessible by these child objects - it's the Animations that go in the Animator that get directly controlled.

    As AC makes use of Unity's animation system, be sure to check out some of the official animation tutorials if you're just starting out.
  • Hi Chris, i followed the instruction in the manual. I get the layers working, it just overrides the animaton underneath, so i get a T-Shirt walking about on it's own. There doesn't seem to be a way to
    tell Unity to render the T-Shirt in it's own Sprite Renderer, so it puts it in the body Sprite Renderer.

    The only solution is to give the T-Shirt layer it's own Animator. But then the Direction and Speed value
    doesn't get passed on.

    I've been watching tutorials, and reading forums, i've spent a lot of time on this, i'm not an expert by
    any stretch, but i'm pretty sure what i what to do isn't possible without scripting.

    Anyway, i can render out all the animation (16 combinations), and do it that way. I would of been super handy to do it the way i wanted, but i'm not stuck completely.

    Thanks for responding. Your side of things is great, and i'm loving using Adventure Creator, i think
    this is a Unity thing.
  • I believe it is a Unity thing, but I'm sure you can have a separate child sprite animated using the same base Animator component.

    What you probably want to do is have something like a final layer that animates the "enabled" state of the T-Shirt sprite renderer / GameObject itself, so that no matter what animation is playing you can separately control whether it's showing or not.  You can then wire up transitions/parameters so that you can control the visiblity of the T-Shirt using Character: Animate.

    You may have better luck asking about this on the Unity forums.
  • Thanks. I think the problem is Unity tries to play both layers through the same Sprite Renderer no matter what I do.
    I found a similar problem on a Unity Forum.
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.