hello.
I have a question. 🙂
Import my spine data into Unity, assign animations and play them.
Then only one animation will play.
I want to do this.
'Idle animation 1 (1 second) {only character animation}
Idle animation 2 (2 Seconds) {only Background animation}
I want to see the combined (animation 1 character ani + 2 bg ani) value in the game window of Unity.'
But in Unity, i will only see the single selected animation.
I ripped through the raptor cs, but I'm dizzy because I can't see the code.
I just want animations 1 and 2 to play simultaneously.
How to play multiple animations simultaneously in Unity without writing any code? :think:
using UnityEngine;
using System.Collections;
using Spine.Unity;
namespace Spine.Unity.Examples
{
public class Raptor : MonoBehaviour
{
#region Inspector
public AnimationReferenceAsset walk;
public AnimationReferenceAsset gungrab;
public AnimationReferenceAsset gunkeep;
#endregion
SkeletonAnimation skeletonAnimation;
void Start()
{
skeletonAnimation = GetComponent<SkeletonAnimation>();
StartCoroutine(GunGrabRoutine());
}
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.0f, 0f));
skeletonAnimation.AnimationState.SetAnimation(1, gungrab, true);
yield return new WaitForSeconds(Random.Range(0.5f, 3f));
skeletonAnimation.AnimationState.SetAnimation(1, gunkeep, false);
}
}
}
}
By modifying the raptor cs code like this, Idle 1 and Idle 2 simultaneous playback was successful.
Would it be okay to do this? :grinteeth:
using UnityEngine;
using System.Collections;
using Spine.Unity;
namespace Spine.Unity.Examples {
public class Raptor : MonoBehaviour {
#region Inspector
public AnimationReferenceAsset walk;
public AnimationReferenceAsset gungrab;
#endregion
SkeletonAnimation skeletonAnimation;
void Start () {
skeletonAnimation = GetComponent<SkeletonAnimation>();
StartCoroutine(GunGrabRoutine());
}
IEnumerator GunGrabRoutine () {
// Play the walk animation on track 0.
skeletonAnimation.AnimationState.SetAnimation(0, walk, true);
skeletonAnimation.AnimationState.SetAnimation(1, gungrab, true);
yield break;
}
}
}
This is how I confirmed that it was playing. 😃