纳金网
标题:
【Unity3d碰撞检测】On Collision Enter
[打印本页]
作者:
铁锹
时间:
2012-12-21 11:42
标题:
【Unity3d碰撞检测】On Collision Enter
1 测试的Cube都给BoxCollider,还要给个Rigidbodyfunction OnCollisionEnter(){Debug.Log("wayne!!!");}function OnCollisionEnter(theCollision:Collision){ if(theCollision.gameObject.name=="Floor"){ Debug.Log("wayne"); }elseif(theCollision.gameObject.name=="Wall"){ Debug.Log("cc"); }}注:这个要把被碰撞的命名。function OnCollisionEnter(obj:Collision){ animation.CrossFade("bianda");Debug.Log(obj.gameObject.name);}注:碰到有Collider的自己播放动画function OnCollisionEnter(){Destroy(gameObject);Debug.Log("wayne!!!");}注:当碰撞到别人摧毁自己。类似子弹。(更多Unity3D碰撞检测教程尽在Web3D纳金网http://www.narkii.com/) 你也可以去这里了解更多关于OnCollisionEnter的问题:http://game.ceeger.com/f***m/simple/?t717.html
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5