NightKot

Hello. Help with advice. I created a character with two Skins, each with two animations. Idle and Walk. In the first the character has an active Idle, in the second Walk. How to switch skins and animations from the code correctly?
NightKot
  • Сообщения: 8

Harald

Please check out the documentation pages here, they explain everything you might need:
spine-unity Runtime Documentation: spine unity Runtime Documentation
Аватара пользователя
Harald

Harri
  • Сообщения: 2778

NightKot

Thank. I will read it.

---

Thank. The problem has been resolved.





using Spine.Unity;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AnimState : StateMachineBehaviour
{
public string animationName;
public string skinName;
public float speed;

override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int LayerIndex)
{

SkeletonAnimation anim = animator.GetComponent<SkeletonAnimation>();
anim.initialSkinName = skinName;
anim.Initialize(true);
anim.state.SetAnimation(0, animationName, true).TimeScale = speed;

}
}
NightKot
  • Сообщения: 8

Harald

Glad you've figured it out, thanks for letting us know.
Аватара пользователя
Harald

Harri
  • Сообщения: 2778


Вернуться в Unity