Hi, i've got a few questions about animations.
1. Random animations
A list of animations that plays randomly when character is not active (in idle) within a set time range.
Example: minimum time to be inactive 10s, maximum 15s to play one of the "random animations" randomly chosen.
Does AC provide a way of doing this or it needs to be scripted manually?
2. Outfits
"Outfit" a set of idle, walk, talk, run animations. I know there's the "Set standard" animation option and it then wants a clip's name. How does this works? If a default set is Name, NameTalk, NameWalk, NameRun, i'll insert for example NameSitting, NameSitingTalk and it will then work with the sufixes? Is there a way to change the whole "outfit" within one action or every part of the set needs to be changed manually?
3. Animations while talking
Usually hand gestures to make the dialogue less static. I have noticed there's a "head on separate layer" option and i suppose that's the thing that could achieve this. How does this work though?
The head should be a child of the character's sprite with its own animations put into the same controller just in another layer?
Then i can run a custom animation during talking that won't break the talking? Or is this meant only for idle to talk while walking? There's of course a lot of animations that requires the head to move with the body (picking up an item from the ground) so i suppose those custom animations contains the head in the original character's body sprite and the head sprite itself needs to be manually hidden before playing these animations.
Thanks for clarifying.
Comments
1. Random animations
This would involve some scripting, but if you rely on Sprites Unity Complex it becomes much easier. You can basically rely on an animation event within your Idle animation to randomly set the value of an Animator parameter, and then use that parameter to control which animation it transitions to when the idle animation completes.
2. Outfits
With Sprites Unity: yes, suffixes will work with the new names, and each standard animation needs to be changed separately (unless you write a custom Action). With Sprites Unity Complex: this is a case of incorporating an Animator parameter (e.g. "IsInCostume" bool) that causes the character to play one of two sets of animations accordingly. You can then change this parameter's value with a single Character: Animate Action. Also know that switching Player prefab in-game is a viable option.
3. Animations while talking
Head-turning is a fairly complex feature, and the implementation depends on the chosen animation engine. A sample package that demonstrates the different options can be found on the Downloads page. Generally though, it does rely on a separate sprite/layer - and allows for animation whenever the character is talking: idle, walking or otherwise.
I've created a sub-state for each outfit in the base layer. It then shows the correct sub-state based on a parameter.
Random animations:
You'have suggested using animation events but i suppose that would means having it inside of every idle direction of every outfit. So i've tried creating something more global with combining these:
1.KickStarter.player.charState (doesn't seem to be detecting custom animations)
2. KickStarter.player.isTalking (why there's not a talk state in charState?)
3. KickStarter.stateHandler.IsInGameplay() (i don't want to play it during dialogs etc. only when nothing is happening)
As there's no such onIdleStart and onIdleStop events i did it inside of the Update method. I'm starting a coroutine when idle starts and stopping it when idle stops.
http://pasteall.org/1048393
The problem is when the idle state is being stopped (eg. character starts walking) while the random animation is playing. The way i understand it is that every animation (custom animations then as well) that are supposed to be played only once and then go back needs to have the has exit time option checked. Otherwise it will keep showing the animation forever (well the last frame - with the loop option unchecked)
I can check with GetCurrentAnimatorStateInfo(0).IsName("Random") if the animation is being played and reset the parameter that triggers the random animation.
So my question is how do i quit these animations? How do i force to stop them immediately? Or maybe i'm trying to create this system in an inconvenient way altogether?
Thanks.
- 1.KickStarter.player.charState (doesn't seem to be detecting custom animations)
The Custom state is not set when using the Mecanim or Sprites Unity Complex engines, due to the separation between animation control (parameters) and the animations themselves.A character can move and talk at the same time.
Rather than reading the charState, I would recommend instead read the character's movement speed. Both this and "isTalking" can be read within the Animator itself - it should be possible to ignore the Char script completely:
http://pasteall.org/1049233/csharp
Oh... there can be both transition with exit time and parameters on the same state. Okay i see it now.
Good point
Thanks, i got it working now.