cookiecarol

Hello,

I've imported a couple of Spine animations into Unity and successfully set it up. When the scene plays, the character automatically plays a looping idle animation. Then there's a button, which triggers a dance animation instead. Like this:
public void getDance()
{
skeletonAnimation.state.SetAnimation(0, "Dance", true);
}
The dance animation is only 150 or so frames long, then I need it to return to the idle animation. However, the way it's set up, it doesn't return and keeps looping the dance.

I tried to research ways I could use spine animations like you would with the "Animator" view with sprite animations. However, I can't seem to find anything. Is it possible to do this? Or does it work completely differently now? How could I program the idle animation to come back after playing the dance once? I've watched all the official Unity tutorials on using the Animator, I'm just confused how to apply it to Spine animations, instead of sprites.

I'm quite new to game development, so the more detailed you can get, the better. Or if there is a tutorial out there I'm just not finding, post it here. Thank you very much for your help! :)

-- 17 Sep 2015, 16:03 --

Okay, so I figured out how to run spine animations in the Animator. (Called mecanim?)

And I researched more and figured out theres a way to set events during the animation, somewhere in the inspector. Can't seem to find this.
cookiecarol
  • Mesajlar: 7

Majicpanda

My only experience with this would be with Mecanim which I would take a look at if you want to have a lot of transitions and states, then all your learning would be with it.

If you did this in Spine with the SetAnimation I assume you would need to create an animation controller with your own logic and correctly queue in the Idle animation with something like...
public void getDance()
{
skeletonAnimation.state.SetAnimation(0, "Dance", true);
skeletonAnimation.state.addAnimation(0, "Idle", true, 0);
}
Majicpanda
  • Mesajlar: 197

cookiecarol

This did exactly what I needed it to do! Thank you very much!
I was looking for these types of code statements in the Unity API, but couldn't find anything. Then when I saw your code addition, it dawned on me that there must be some sort of coding guide for Spine and I found this. http://esotericsoftware.com/spine-using-runtimes#AnimationState
I see the type of code you wrote in there. So I'll read up more on this.


If anyone has any information on how to use spine animations with mecanim/Animator, that would be great. I would still love to learn how to use the events, so I could put sound effects in. I looked over this tutorial, but I can't seem to find the "Events" dropdown anywhere. https://www.youtube.com/watch?v=8VG2aK2AGSk
cookiecarol
  • Mesajlar: 7

ciaps

Hi @Majicpanda and @Cookiecarol,

I am struggling with the same issue, I am not able to play smooth transitions between animations, using parameters read from a Mecanim Animator.

so you are saying that you are still instantiating the Spine Character as SkeletonAnimation, and then attach an Animator component, that you then link to a new animator controller?

This is interesting, in this way you can use both the Spine runtimes and the state machines with parameters.

I have a couple of questions though:

1) The code for starting an animation (SetAnimation method) would be called when you enter the state in the state machine? I mean, would it be in a script attached to a particular state of the state machine? Or you would trigger it through script? In the second case, I would then not see the advantage of this ststem

2) Would the transitions between states, peculiarity of Mecanim, work properly then?

Thanks for reading, and for your help !
Kullanıcı avatarı
ciaps
  • Mesajlar: 21

Majicpanda

I only use Instantiate > Mecanim and the default Spine Animator that is on the object.. I don't mix and match. We have 2 different topics going on here.

The thing I found with Mecanim is it's extremely important to get your transition exit times correct or you'll see some quirky behavior. What exactly isn't smooth? Trigger instant transitions or basic exit time transitions?

This may be completely wrong, but for trigger Any State > State transitions I click "Has Exit Time" and then set exit time to 0, then uncheck it.. then set fixed duration for the transition to .01 and things seemed 100x better for me.

For a chained melee attack that goes from slash 1 > 2 > 3 I had to set has exit time to 1.0 and then check fixed duration and set it at 0. I did something kind of tricky here and put the condition as "Melee Attack" which is a bool in my game and then "AttackNormalizedTime" which is a float updated by the current animation's normalized time and set it to Greater than .95f.. so what happens is the animation reports to itself how far into it that it is and then transitions out if the user clicked to chain another melee attack. If they did not.. it exit time's back to Idle with Has Exit Time 1.0f and fixed duration .1f ...

None of this makes sense to me, I just kept tweaking til I saw the results I needed.
Majicpanda
  • Mesajlar: 197

ciaps

Hi Majicpanda,

thanks for your reply.

I am actually referring to a mixing problem that I have, as my character in a point&click adventure either has super weird poses, either -using SetToSetupPose and ClearTracks- stops to do any kind of mixing animations.

I actually just opened a new thread http://esotericsoftware.com/forum/Problem-with-mixing-animations-5272 for this problem, maybe you can help as well!
Kullanıcı avatarı
ciaps
  • Mesajlar: 21


Dön Unity