纳金网
标题:
unity3d 点击地形某一点,第一人称定位过去?
[打印本页]
作者:
她。
时间:
2013-5-22 10:44
标题:
unity3d 点击地形某一点,第一人称定位过去?
public GameObject cameraObj;
void OnMouseDown()
{
Vector3 objVector3 = Camera.mainCamera.WorldToScreenPoint(this.cameraObj.transform.position);
Vector3 off = new Vector3(Input.mousePosition.x - objVector3.x, Input.mousePosition.y - objVector3.y, objVector3.z);
Vector3 mousePositon = new Vector3(off.x +off.x+ Input.mousePosition.x,off.y +off.y+ Input.mousePosition.y, off.z);
Vector3 posit = Camera.mainCamera.ScreenToWorldPoint(mousePositon);
cameraObj.transform.position = new Vector3(posit.x,0.7499999f,posit.z);
}
把脚本赋给地形, 点击移动有问题。 谁有好的方法,告诉我一下
欢迎光临 纳金网 (http://course.narkii.com/club/)
Powered by Discuz! X2.5