Кто-нибудь может сказать мне, почему мои триггеры не работают, когда я использую этот скрипт? это используется в сочетании с ползунком для просмотра анимации:
public class AnimatorControl : MonoBehaviour
{
public Animator anim;
public Slider slider; //Assign the UI slider of your scene in this slot
//public string animatorClipName;
Animator m_Animator;
public int i;
string m_ClipName;
AnimatorClipInfo[] m_CurrentClipInfo;
float m_CurrentClipLength;
float timer;
// public int currentFrame;
// Use this for initialization
void Start()
{
anim = GetComponent<Animator>();
//Get them_Animator, which you attach to the GameObject you intend to animate.
m_Animator = gameObject.GetComponent<Animator>();
//Fetch the current Animation clip information for the base layer
m_CurrentClipInfo = this.m_Animator.GetCurrentAnimatorClipInfo(0);
//Access the current length of the clip
m_CurrentClipLength = m_CurrentClipInfo[0].clip.length;
//Access the Animation clip name
m_ClipName = m_CurrentClipInfo[0].clip.name;
timer = (1 / m_CurrentClipLength) / 60;
}
// Update is called once per frame
void Update()
{
int currentFrame = (int)(m_CurrentClipInfo[0].weight * (m_CurrentClipInfo[0].clip.length *
m_CurrentClipInfo[0].clip.frameRate));
int w = anim.GetCurrentAnimatorClipInfo(0).Length;
string[] clipName = new string[w];
if (Input.GetKeyDown(KeyCode.Space)) anim.SetTrigger("Next");
for (int i = 0; i < w; i += 1)
{
clipName[i] = anim.GetCurrentAnimatorClipInfo(0)[i].clip.name;
Debug.Log(clipName[i]);
string clip = clipName[i].ToString();
// anim.Play(clip, 0, slider.normalizedValue);
}
// Debug.Log(m_CurrentClipInfo[0].clip.name);
slider.normalizedValue += timer;
}
}
Я использую пробел для перемещения анимационного перехода в аниматоре, который работает. Когда я использую anim.Play(clip, 0, slider.normalizedValue);
, мои триггеры не будут работать. Если я уберу anim.Play(clip, 0, slider.normalizedValue);
, триггеры снова начнут работать ...