MonoBehaviour.OnTriggerExit 当退出触发器

function OnTriggerExit (other : Collider) : void

Description描述

OnTriggerExit is called when the Collider other has stopped touching the trigger .

当Collider(碰撞体)停止触发trigger(触发器)时调用OnTriggerExit。

This message is sent to the trigger and the collider that touches the trigger. Note that trigger events are only sent if one of the colliders also has a rigid body attached.

这个消息被发送到触发器和接触到这个触发器的碰撞体。注意如果碰撞体附加了一个刚体,也只发送触发器事件。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnTriggerExit(Collider other) {
		Destroy(other.gameObject);
	}
}
// Destroy everything that leaves the trigger
// 销毁所有离开触发器的物体
function OnTriggerExit (other : Collider ) {
	Destroy(other.gameObject);
}

OnTriggerExit can be a co-routine, simply use the yield statement in the function.

OnTriggerExit可以被用作协同程序,在函数中调用yield语句。

最后修改:2011年1月2日 Sunday 15:41

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。