Unity3D 判断两个物体相交脚本
Posted on 2013 年 02 月 25 日 by U3d / Unity3D 脚本/插件/被围观 285 次
Unity3D 中有两个 GameObject a b Collider 均为 Trigger。
var target:GameObject
function Update()
{
if(!target)
{
renderer.material.color=Color.white;
}
}
function OnTriggerEnter(col:Collider)
{
target=col.gameObject;
renderer.material.color=Color.red;
}
此做法是比较浪费资源,需要 Update 一直执行。有更好的方法欢迎来搞!