Unity ScreentoWorldPoint中的z坐标说明
2016-04-28 19:45
651 查看
There are two problems here. The first one is that you need a 'new' in front of your Vector3() in C#. The second is that the 'z' parameter must be the distance in front of the camera. In perspective mode at least, passing 0 will cause ScreenToWorldPoint()
to always return the position of the camera. So the call will look something like:
[/code]
Note the measurement for the 'z' parameter is from camera plane to the playing surface plane. It is not the distance between the camera and the object. If the camera is aligned with the axes, then the distance is easy to calculate. If the camera is at an
angle (i.e. not axes aligned), then ScreenToWorldPoint() is not the way to go.
Correction/Addition: Passing '0' will work fine to find the world x,y values if the camera is Orthographic. The 'z' will be the 'z' position of the camera.
原文地址:http://answers.unity3d.com/questions/599097/need-help-understanding-screentoworldpoint.html
to always return the position of the camera. So the call will look something like:
worldPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y, 10.0f));
[/code]
Note the measurement for the 'z' parameter is from camera plane to the playing surface plane. It is not the distance between the camera and the object. If the camera is aligned with the axes, then the distance is easy to calculate. If the camera is at an
angle (i.e. not axes aligned), then ScreenToWorldPoint() is not the way to go.
Correction/Addition: Passing '0' will work fine to find the world x,y values if the camera is Orthographic. The 'z' will be the 'z' position of the camera.
原文地址:http://answers.unity3d.com/questions/599097/need-help-understanding-screentoworldpoint.html
相关文章推荐
- Unity3D的几种坐标系
- unity3D 彻底搞懂 Quaternion LookRotation FromToRotation SetLookRotation方法
- Visual Studio 2015 Tools for Unity安装
- Unity协程和线程的区别
- Unity3D 动态创建Mesh
- Unity5.3.4以前的旧版本打包问题Xcode7.3编译问题 Error "unknown type name __declspec" after Xcode 7.3 upgrade
- Unity和Android互相调用
- Unity Animator动画倒播方法
- unity3D ——自带寻路Navmesh入门教程(一)(转)
- unity3D——自带寻路Navmesh入门教程(二)(转)
- 优化unity发布 iOS应用大小 Optimizing the Size of the Built iOS Player<转>
- 星空大战 Unity版本
- 【bug】对象激活前无法通过调用脚本函数设置变量
- unity, Graphics.Blit (null, null, mat,0);
- Unity IMGUI
- unity3d——自带寻路Navmesh (三)(转)
- Unity 服务器时间
- unity异常处理的方法
- unity多渠道sdk打包.
- 官网Unity3Dshader解析,好文章,记录下