吃草莓之后音效无法正常播放,并且后面一行消除草莓的代码没有运行
private AudioSource audioSource;
public void PlaySound(AudioClip audioClip)
{
audioSource.PlayOneShot(audioClip);
}
}
public AudioClip se;
private void OnTriggerEnter2D(Collider2D collision)
{
RubyController rubyController = collision.GetComponent<RubyController>();
//当前接触触发器的物体身上是否有Rubycontroller脚本
if (rubyController!=null)
{
//判断Ruby是否满血
if (rubyController.DangqianHP<rubyController.maxHP)
{
rubyController.ChangeHP(1);
rubyController.PlaySound(se);
Destroy(gameObject);
}
}
}