打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Unity 3d 射线检测(获得鼠标点击的坐标[x,y,z])
userphoto

2014.04.17

关注
  • using UnityEngine;
  • using System.Collections;

  • public class Lu : MonoBehaviour{
  • public Camera cam;
  • // We need to actually hit an object
  • RaycastHit hitt = new RaycastHit();
  • // Use this for initialization

  • void Start() {

  • }
  • // Update is called once per frame

  • void Update() {
  • Ray ray = cam.ScreenPointToRay(Input.mousePosition);
  • Physics.Raycast(ray, out hitt, 100);
  • // Debug.DrawLine(cam.transform.position, ray.direction,Color.red);
  • if (null != hitt.transform) {
  • print(hitt.point);
  • //鼠标点击的坐标
  • }
  • }

  • }
  • 本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
    打开APP,阅读全文并永久保存 查看更多类似文章
    猜你喜欢
    类似文章
    UNITY2d检测方法OverlapCircle与Raycast详解 | 航行学园
    X射线检测X-Ray
    18:unity3d
    Unity3D 之射线检测
    Unity3d中屏幕点转化为世界点通过射线
    Ray Metzker射线Metzker
    更多类似文章 >>
    生活服务
    热点新闻
    分享 收藏 导长图 关注 下载文章
    绑定账号成功
    后续可登录账号畅享VIP特权!
    如果VIP功能使用有故障,
    可点击这里联系客服!

    联系客服