Multi Layer Spine Animation - SkeletonAnimation
✍ Last Updated : October 3, 2022
🚪 Prequisite Knowledge (Optional)
Know how to setup and basic implementation of spine on Unity
spine-unity Runtime Documentation
❓ Key Question / Problem / Issue
How to achieve multi layer animation with Spine ?
✅ Expected Output/Definition of Done
Can apply multi layer animation blending in same time, such as Running while Shooting target. Instead of directly change all animation, it can be achieved by using multi layer, on this case animation will have two layer which are top and upper body. Changing the upper body from default to shooting state.
🎁 Resulting Solution
Direct Set
Example of Multi layer animation from spine tutorial
On this example it’s separated into two track , track 0 will be handle lower body animation and track 1 will handle the top.
IEnumerator GunGrabRoutine () {
// Play the walk animation on track 0.
skeletonAnimation.AnimationState.SetAnimation(0, walk, true);
// Repeatedly play the gungrab and gunkeep animation on track 1.
while (true) {
yield return new WaitForSeconds(Random.Range(0.5f, 3f));
skeletonAnimation.AnimationState.SetAnimation(1, gungrab, false);
yield return new WaitForSeconds(Random.Range(0.5f, 3f));
skeletonAnimation.AnimationState.SetAnimation(1, gunkeep, false);
}
}
The example snippet code simply use Spine.AnimationState.setAnimation API. By modifying track index you can change on which track animation will be played.
setAnimation (sint trackIndex, Animation animation, bool loop): TrackEntry
Combine with Timeline Unity
//TODO
Notes
- Need to test if there are two animation on different track but modify same parts of body
- Need to research for more complex multi layer animations such as on fighting animations
No Comments