- Edited
Animation control in Unity C#
I got a character animation controller going in Unity fully functional and almost good to go.
However, Unity is unexpectedly better than I thought at mixing animation even at default setup without any blend trees.
So, what I've ran into is some of my transition animation being cut off or not played in several case scenarios because my transition animations are way too isolated at this state(like, when character jumping I have 'jump,' 'jumpToFall,' 'fallToLand,' and then 'landToIdle' or 'landToWalk.')
In order to resolve this I have a few thoughts on my mind, but think trying too hard myself would be too amateurish.
How my animation control is setup at current is while my character movement control script provides state of the character's current action state (i.e. walking, running, jumping, landing, etc...) and another script(animation controller script) receives the state data (did this the dirty way with enum wishing I could do better with something else I don't quite get atm) and plays animation when match with list of if statements.
My initial idea about resolving my case was to manually set animations to play in order (like, play anim_1 to full duration then anim_x plays right after basically prioritize what comes before than what animation controller script currently will play) but I'm quite new to Spine Unity Runtime so...
Can someone guide me to list of API or whatever information I should be aware of to resolve this in coding-side instead of animating-again side, please? I'll be greatly appreciated.
Are you talking about SetAnimation vs AddAnimation?
Xelnath wroteAre you talking about SetAnimation vs AddAnimation?
Similar. I did want to know in what ways either SetAnimation & AddAnimation or any other Spine.Unity syntax can prevent my current issue.
At my current understanding level of Spine-Unity Documentation I still can't figure out how to prevent animation B from playing before animation A plays to its own end frame. Of course, what caused my current issue (i.e. 'idle_x animation' playing before 'landing animation') is due to how I set up my animation controlling method, but if there was a way to play several animations subsequently in code-side I wanted to know ' '.
30 Oct 2016, 15:36
Affinity wroteXelnath wroteAre you talking about SetAnimation vs AddAnimation?
Similar. I did want to know in what ways either SetAnimation & AddAnimation or any other Spine.Unity syntax can prevent my current issue.
At my current understanding level of Spine-Unity Documentation I still can't figure out how to prevent animation B from playing before animation A plays to its own end frame. Of course, what caused my current issue (i.e. 'idle_x animation' playing before 'landing animation') is due to how I set up my animation controlling method, but if there was a way to play several animations subsequently in code-side I wanted to know ' '.
Found that I was useing 'skeletonAnimation.state.setAnimation()' and 'skeletonAnimation.state.addAnimation()' wrong. this it what more precisely is bugging me on my animation controller.
:
my transition animation between anim_1 and anim_2 still doesn't play fully as well as anim_1 still skipping later frames before animations on 'addAnimation' side plays.
here's my code:
if (player.state == ActState.jumping)
{
pcAnim.state.SetAnimation(2, "jump", false);
pcAnim.state.AddAnimation(1, "trans_jumpToFall", false, 0);
pcAnim.state.AddAnimation(0, "fall", true, 0);
30 10 2016, 17:55
SOLVED!
Turns out my animation trigger method (via enum and using it as flags) was very inconsistent for animation triggering!
Having enum to verify what action state PC is in was working well, but disturbed hell lot for Spine.Unity in C# to function consistently.
Still want to have similar categorizing function for PC's current action/behavior in future, but seems enum flagging and spine just dont go well. Just bounded all my desired animation triggering and ordering to specific inputs and variables. Perhaps this is the quick and dirty way of doing it-I'm still not sure about XP