Collider.OnTriggerEnter 进入触发器
function OnTriggerEnter (other : Collider) : void
Description描述
OnTriggerEnter is called when the Collider other enters the trigger.
当碰撞器other进入触发器时OnTriggerEnter被调用。
This message is sent to the trigger collider and the rigidbody (or the collider if there is no rigidbody) that touches the trigger. Note that trigger events are only sent if one of the colliders also has a rigidbody attached.
这个消息是发送给触动触发器的碰撞器和刚体(或如果没有刚体的碰撞器)。注意假如一个碰撞物体同时带有一个刚体属性
那么只发送这个触发事件。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnTriggerEnter(Collider other) {
Destroy(other.gameObject);
}
}
// Destroy everything that enters the trigger
//当进入触发器销毁所有物体
function OnTriggerEnter (other : Collider) {
Destroy(other.gameObject);
}
最后修改:2010年12月12日 Sunday 15:23