Animation Problems writing a sequence

Announcements, support questions, and discussion for the Dialogue System.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Animation Problems writing a sequence

Post by OneManOnMars »

Hi,

I am working on sequences right now so I had a good look at the built in command list. So far so good.
Here is my test script:

Fade(in,2); SetActive(HERO_SCENE_PREFAB, false);SetActiveHero_Puppet, true); SetEnabled(animationRandomizer, false, SpineMentor); AnimatorPlay(IDLE_ALT0, Hero_Puppet)@2;

What I do here is replaceing my ingame player character with a puppet (Spine Mecanim animated)
I do that because I have the problem, that when I trigger Animations with f.e. AnimatorPlay(IDLE_ALT0, Hero_Puppet)@2; the animation gets played but only for one frame. So after deactivating a lot of scripts that control the character I thought I test it with just the spine gameobject wich is my Hero_Puppet. This way I can exclude that it is for any another reason. (I had the same problem with my player character, hence thats way I am doing all this :-) )

Ok, when I start the animatin it gets played for one frame, after that it jumps back to idle.

Image

I did some test with the animator because something has to push it back to idle for some reasons. So what I did is to delete the transition from Any State to IDLE. And from there on it worked. But well, deleting this transition is no solution because I need it.
Well I could create a new controller for the puppet. But to be honest I would prefer not to use the puppet in the first place.

Do you have any idea how I can work around this problem?

This would be soooo very helpful!

Thank you in advance!
User avatar
Tony Li
Posts: 21081
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation Problems writing a sequence

Post by Tony Li »

Hi,

It looks like it's transitioning to IDLE because State Equals 0. (Also presumably PreviousState != 100.)

What if you temporarily set State to another value using AnimatorInt():

Code: Select all

AnimatorInt(State, 9999, Hero_Puppet)
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Animation Problems writing a sequence

Post by OneManOnMars »

Thanks for the feedback. But it gives me the same result as before. It jumps to the new state, but then quickly jumps back to 0. Something has to push it to that state. But I have no idea what. Could it be the loop? Edit: Nope, the loop its not.


Image
Interestingly, if I type in a 10 under parameters when the game is running then it works... but If I call the 10 (state) via sequence script. It does not work
Last edited by OneManOnMars on Thu Mar 23, 2017 1:45 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21081
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation Problems writing a sequence

Post by Tony Li »

While playing, select the Hero_Puppet and keep an eye on the Animator window. Is a script perhaps setting State back to 0? Does Hero_Puppet have any scripts that set animator parameters in Update(), FixedUpdate(), or LateUpdate()? (Or a coroutine?)

You wrote that it works when you deleted the transition from Any State to IDLE. So the solution is to make sure the transition's conditions stay false until you really want to return to IDLE.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Animation Problems writing a sequence

Post by OneManOnMars »

Tony Li wrote:While playing, select the Hero_Puppet and keep an eye on the Animator window. Is a script perhaps setting State back to 0? Does Hero_Puppet have any scripts that set animator parameters in Update(), FixedUpdate(), or LateUpdate()? (Or a coroutine?)

You wrote that it works when you deleted the transition from Any State to IDLE. So the solution is to make sure the transition's conditions stay false until you really want to return to IDLE.


Image
Thats why I created the puppet. To make sure no script manipulates it. Its just the spine animator, mesh renderer and the skeleton Animator on it. Everything is default Spine stuff. AND what I have problem with does work if I use a simpler Animation controller. With no state transitions.
So it has to be something with the controller

Not even adding "State not equal 10" to the transition from any state to IDLE does help.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Animation Problems writing a sequence

Post by OneManOnMars »

:idea:

Think I found a solution. Its not Notequal 10 that worked, but "Previous state != 10" this works at the moment. I'll see if I can work with that.
This could end in a problem, if I want to use walk in a sequence because I could not ad the condition don't go to idle if the previous state was walk. That would kill the game.

But for now it does work. Altough I am still currious to know why the idle state 0 is sooooo strong.
User avatar
Tony Li
Posts: 21081
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation Problems writing a sequence

Post by Tony Li »

Maybe State starts at 0, so that's why it's immediately transitioning to IDLE.

Try this:

Code: Select all

Fade(in,2); 
SetActive(HERO_SCENE_PREFAB, false);
SetActive(Hero_Puppet, true); 
SetEnabled(animationRandomizer, false, SpineMentor); 
AnimatorInt(State, 9999, Hero_Puppet);
AnimatorPlay(IDLE_ALT0, Hero_Puppet)@2;
I added the next-to-last line. It sets State to 9999.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Animation Problems writing a sequence

Post by OneManOnMars »

Thanks Tony! Your very helpful, as allways. I do really appreciate that!

Your solution does work with a simple addition: I have to add: PreviousSTate Notequal 9999 to the transition to IDLE!

Like that it does not want to go back to idle anymore. And like this I can play any animation without changing the controller in a bad way.

I tested it with this scrip:
Fade(in,2); AnimatorInt(State, 9999, Hero_Sprite); SetEnabled(Character, false, HERO_SCENE_PREFAB, )@1; SetEnabled(UnitySpriteDirectionFacer, false, Hero_Sprite); SetEnabled(MecanimAnimationBridge_3D, false, Hero_Sprite);SetEnabled(animationRandomizer, false, SpineMentor); AnimatorPlay(IDLE_ALT0, listener)@0.1; AnimatorPlay(WALK, listener)@3; AnimatorPlay(ATTACK, listener)@4; AnimatorPlay(IDLE_ALT2, listener)@7;

and it does work! Thank you so much. This gives this day a positiv ending after a loooot of pita :lol:

Thank you Tony!
Last edited by OneManOnMars on Thu Mar 23, 2017 2:55 pm, edited 1 time in total.
OneManOnMars
Posts: 105
Joined: Tue Apr 05, 2016 9:37 am

Re: Animation Problems writing a sequence

Post by OneManOnMars »

Bye the way, is there a command to start a conversation from a sequence. This sequence is started on start. But it should start a conversation at one point. Is that possible. There seems not to be a command in the list.

If you want me to start a new thread for that, please let me know.

Sorry, for not stoping asking questions :?
User avatar
Tony Li
Posts: 21081
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation Problems writing a sequence

Post by Tony Li »

OneManOnMars wrote:By the way, is there a command to start a conversation from a sequence. This sequence is started on start. But it should start a conversation at one point. Is that possible. There seems not to be a command in the list.
No need to start a new thread, and I'm happy answer questions. :-) There is no sequencer command to start a conversation. If you don't want to write your own, you can use these steps:

1. Create a Conversation Trigger on a uniquely-named GameObject. Let's say it's called "ConvStarter".

2. Configure the Conversation Trigger's conversation, actor, and conversant. Set the trigger to OnUse.

3. In the sequence, use a command like this:

Code: Select all

SendMessage(OnUse,,ConvStarter)
Post Reply