【问题标题】:Stop animation OnTriggerExit停止动画 OnTriggerExit
【发布时间】:2015-10-08 06:50:47
【问题描述】:

我正在使用 collider 播放我的动画 onTriggerEnter 并希望停止动画 onTriggerExit 并再次播放 onTriggerEnter 等等。

这是 onTriggerEnter 脚本:

var chestSound : AudioClip;
var treasureChest : GameObject; 
function OnTriggerEnter (col : Collider) {
    if(col.gameObject.tag == "Player") { 
        AudioSource.PlayClipAtPoint(chestSound, transform.position);
        treasureChest.animation.Play();
        Destroy(gameObject);
    }
}

【问题讨论】:

  • 这个例子怎么样? link
  • 在本例中 onTriggerExit 播放另一个动画我只想停止动画 onTriggerExit 再次播放 onTriggerEnter。
  • 到底出了什么问题?你试过使用treasureChest.animation.Stop();吗?
  • 你能写出 onTriggerExit 的代码吗?

标签: animation unity3d unityscript


【解决方案1】:

好吧,我会写

function OnTriggerExit (col : Collider) {
 if(col.gameObject.tag == "Player") 
     treasureChest.animation.Stop();
 }

但似乎您对Destroy(gameObject) 的使用可能会影响游戏。当他触发另一个对象时,您正在破坏自己的播放器对象,他怎么能通过 OnTriggerExit?

【讨论】:

  • 是的,你在写我只是删除了这个 Destroy(gameObject) 及其工作,谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-15
  • 2016-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多