射线检测碰撞换Tag

来源:互联网 发布:虚幻4引擎源码下载 编辑:程序博客网 时间:2024/05/21 05:05
//从角色位置向NPC发射一条经过鼠标位置的射线Ray mRay=Camera.main.ScreenPointToRay(Input.mousePosition);RaycastHit mHi;if(Physics.Raycast(mRay,out mHi)) {if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))       {        if(Vector3 .Distance (this .transform.position  ,mHi .transform.position  )<10)        {            if(mHi.collider.gameObject.tag=="NPC"             {                   Debug.log("You Got It")            }}      }}
0 0
原创粉丝点击