unity3d 碰撞中不检测图片透明部分怎么弄啊
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);//从摄像机发出到点击坐标的射线
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo))
{
//Debug.DrawLine(ray.origin, hitInfo.point);//划出射线,在scene视图中能看到由摄像机发射出的射线
GameObject gameObj = hitInfo.collider.gameObject;
//Debug.Log(gameObj.name);
selectObj = gameObj;
Vector3 Mousepoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
MouseDownPostion = new Vector3(gameObj.transform.position.x - Mousepoint.x, gameObj.transform.position.y - Mousepoint.y, 0);
isMouseDown = true;
}
用的collider box来检测碰撞,但是目标是sprite,包含透明通道,所以想点在透明的部分就不被碰撞检测到该怎么办或者提供下思路呢
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo))
{
//Debug.DrawLine(ray.origin, hitInfo.point);//划出射线,在scene视图中能看到由摄像机发射出的射线
GameObject gameObj = hitInfo.collider.gameObject;
//Debug.Log(gameObj.name);
selectObj = gameObj;
Vector3 Mousepoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
MouseDownPostion = new Vector3(gameObj.transform.position.x - Mousepoint.x, gameObj.transform.position.y - Mousepoint.y, 0);
isMouseDown = true;
}
用的collider box来检测碰撞,但是目标是sprite,包含透明通道,所以想点在透明的部分就不被碰撞检测到该怎么办或者提供下思路呢
...全文
相关推荐
Unity3d中的碰撞检测教程
### Unity3D中的碰撞检测详解#### 一、引言在Unity3D游戏开发过程中,碰撞检测是一项非常重要的技术。
[Unity3D]Unity3D官方案例SpaceShooter开发教程
1、先导入SpaceShooter的环境资源,将Models下的vehicle_playerShip放到Hierachy窗口,改名为Player.Rotation x改为270,为Player添加mesh collider组件,将vehicle_playerShip_collider放到Mesh属性里面,为Player添加刚体,去掉重力的勾选,将Prefebs中的engines_player放到H
Unity3D入门 :简单的碰撞检测
在Unity3D游戏开发中,碰撞检测是至关重要的一个环节,它使得游戏对象能够感知到彼此之间的接触,从而触发各种事件,如伤害计算、交互反馈等。本教程将引导初学者掌握Unity3D中的基本碰撞检测机制。
Unity3d插件实现半透明效果
在代码部分,我们使用 RaycastHit[] hits 来存储射线碰撞结果,然后遍历 hits 数组,获取每个碰撞结果的 renderer,对其应用特殊的 shader 实现半透明效果。
Unity3d非物理引擎模拟碰撞效果
但在非物理引擎模拟中,我们可能不需要Rigidbody,而是直接通过脚本检测和处理碰撞。1.



