Hi guys,
I'm wondering if someone can help me, I'm creating a sprite based adventure game using the Sprites Unity mode and am trying to implement layered animations to allow a little bit more flexibility with character movements, facial expressions, etc.
Currently I've set up an NPC so that the main body is on one layer (the sprite child), with a separate sprite for the mouth/lower jaw and eyes/forehead sections of the head, nested as children of the sprite child. The idea is that we can switch out the head sprites to allow the characters to talk/have different expressions whilst leaving the rest of the body free for other anims.
I've created a talk cycle for the lower jaw but can't for the life of me work out how to configure it between AC and the Animator Controller. I've tried putting the Talk anims on a separate layer, but in this case they don't seem to be called at all and if I put them on the base layer, the talk cycle will replace the character's body, leaving a mouth talking beneath a disembodied head.
I'm sure there's something very simple that I'm missing and have spent hours looking through the Unity documentation, AC documentation and various YouTube tutorials to try and find a solution, but nothing I've found quite seems to fit. It's occurred to me that I could play and stop the custom animation after every dialogue line but surely there is a more simple way?
Any help would be very much appreciated!
Cheers!
DB
Comments
Sprites Unity Complex is very similar to the standard Mecanim workflow - instead of defining standard animations to play, you instead create your Animator controller the way you want, and then define parameters that AC can then control (e.g. a "Move speed" float, an "Is talking?" bool). These parameters are layer-independent, so you can use them to control your Animator Controller however you like. See section 3.9 of the Manual for more.
Hi Chris,
Can you confirm how the nesting for the sprites should work for Sprites Unity Complex please? Currently I've got it set up so that there is a game object with the NPC component, etc. attached to it, then under this I have an empty game object with the animator component on it (my "sprite child") and a "follow sorting map" component. Then nested under that I have the different layer sprites, each with their own sprite renderer and appropriate sorting layer specified. The "follow sorting map" component on the sprite child is set to follow default sorting map, offset original order and also affect children.
When I play the game, I can see the animations triggering in the animator, with the exception that it appears to have left and right mixed up, (left being triggered when the Direction parameter is set to 1 & right when it's set to 2). However, the animations aren't visible in the game window, the sprites just remain in their idle state. The clips are all hooked up as far as I can see and they appear correctly when viewed outside of the game. In the animator, the layers are set to override, with a weight of 1.
If the correct animations are playing in the Animator window, then it sounds like AC at least is doing it's job properly. My first instinct woud be to check the animations themselves are working - if you remove the NPC component to "free" it from AC, do they then play when you set the Animator parameters manually?
I'm not understandng too well what your issue with the frame-flipping is - screenshots would help clarify. However, the feature works by changing the inverting the x-scale of the sprite child - so you may have trouble if you control the scale through animation also.