質問編集履歴
4
cosの図の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -77,7 +77,8 @@
|
|
77
77
|
```
|
78
78
|
|
79
79
|
### 追記②
|
80
|
+
cosの図が間違ってたので修正しました。
|
80
|
-

|
81
82
|
|
82
83
|
### メモ
|
83
84
|
|
3
メモ追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -77,4 +77,10 @@
|
|
77
77
|
```
|
78
78
|
|
79
79
|
### 追記②
|
80
|
-

|
80
|
+

|
81
|
+
|
82
|
+
### メモ
|
83
|
+
|
84
|
+
nDir・forward = cosθ
|
85
|
+
v=nDir/cosθ
|
86
|
+
v=nDir/nDir・forward
|
2
図の挿入
title
CHANGED
File without changes
|
body
CHANGED
@@ -74,4 +74,7 @@
|
|
74
74
|
Debug.Log("cubeViewport2.y:" + cubeViewport2.y); //0.5999997
|
75
75
|
Debug.Log("cubeViewport2.z:" + cubeViewport2.z); //7.229684
|
76
76
|
Debug.Log(Vector3.Distance(Camera.main.transform.position, cube.transform.position)); //9.727413
|
77
|
-
```
|
77
|
+
```
|
78
|
+
|
79
|
+
### 追記②
|
80
|
+

|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -54,4 +54,24 @@
|
|
54
54
|
```
|
55
55
|
Camera.main.transform.forward * 5 は、x,yに影響を与えないかと思っていたのですが、
|
56
56
|
なぜ、cubeViewport.xが0.8fに、cubeViewport.yが0.6fにならないのでしょうか?
|
57
|
-
誤差にしては大き過ぎると思いました。
|
57
|
+
誤差にしては大き過ぎると思いました。
|
58
|
+
|
59
|
+
### 追記
|
60
|
+
|
61
|
+
```C#
|
62
|
+
Vector3 worldpos = Camera.main.ViewportToWorldPoint(new Vector3(0.8f, 0.6f, 5f));
|
63
|
+
cube.transform.position = worldpos;
|
64
|
+
Vector3 cubeViewport = Camera.main.WorldToViewportPoint(cube.transform.position);
|
65
|
+
Debug.Log("cubeViewport.x:" + cubeViewport.x); //0.7999997
|
66
|
+
Debug.Log("cubeViewport.y:" + cubeViewport.y); //0.5999997
|
67
|
+
Debug.Log("cubeViewport.z:" + cubeViewport.z); //5
|
68
|
+
Debug.Log(Vector3.Distance(Camera.main.transform.position, cube.transform.position)); //6.727412
|
69
|
+
|
70
|
+
Vector3 dir = cube.transform.position - Camera.main.transform.position;
|
71
|
+
cube.transform.position = cube.transform.position + Vector3.Normalize(dir)*3;
|
72
|
+
Vector3 cubeViewport2 = Camera.main.WorldToViewportPoint(cube.transform.position);
|
73
|
+
Debug.Log("cubeViewport2.x:" + cubeViewport2.x); //0.7999997
|
74
|
+
Debug.Log("cubeViewport2.y:" + cubeViewport2.y); //0.5999997
|
75
|
+
Debug.Log("cubeViewport2.z:" + cubeViewport2.z); //7.229684
|
76
|
+
Debug.Log(Vector3.Distance(Camera.main.transform.position, cube.transform.position)); //9.727413
|
77
|
+
```
|