質問編集履歴
1
スクリプトを更新しました、
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,71 +18,75 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
public class
|
21
|
+
public class ray2 : MonoBehaviour
|
22
22
|
|
23
23
|
{
|
24
24
|
|
25
|
-
|
25
|
+
//public GameObject targetObject;
|
26
26
|
|
27
|
+
|
28
|
+
|
29
|
+
Vector3 m_ZAixs;
|
30
|
+
|
31
|
+
public Rigidbody m_Rigidbody;
|
32
|
+
|
27
|
-
p
|
33
|
+
public GameObject Light;
|
34
|
+
|
35
|
+
// Use this for initialization
|
28
36
|
|
29
37
|
void Start()
|
30
38
|
|
31
39
|
{
|
32
40
|
|
41
|
+
m_Rigidbody = Light.GetComponent<Rigidbody>();
|
42
|
+
|
43
|
+
m_Rigidbody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionZ;
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
// Update is called once per frame
|
48
|
+
|
33
49
|
}
|
34
|
-
|
35
|
-
// Update is called once per frame
|
36
50
|
|
37
51
|
void Update()
|
38
52
|
|
39
53
|
{
|
40
54
|
|
41
|
-
Vector2 touchScreenPosition = Input.mousePosition;
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
touchScreenPosition.x = Mathf.Clamp(touchScreenPosition.x, 0.0f, Screen.width);
|
46
|
-
|
47
|
-
touchScreenPosition.y = Mathf.Clamp(touchScreenPosition.y, 0.0f, Screen.height);
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Camera gameCamera = Camera.main;
|
52
|
-
|
53
|
-
Ray touchPointToRay = gameCamera.ScreenPointToRay(touchScreenPosition);
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
RaycastHit hitInfo = new RaycastHit();
|
58
|
-
|
59
|
-
if (
|
55
|
+
if (Input.GetMouseButtonDown(0))
|
60
56
|
|
61
57
|
{
|
62
58
|
|
59
|
+
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
60
|
+
|
61
|
+
RaycastHit hit;
|
62
|
+
|
63
|
+
if (Physics.Raycast(ray, out hit, Mathf.Infinity))
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
GameObject t = GameObject.Find("SpotLightWhite 1 1(Clone)");
|
68
|
+
|
69
|
+
var targetPos = new Vector3(hit.point.x, hit.point.y, hit.point.z);
|
70
|
+
|
63
|
-
|
71
|
+
t.transform.position = targetPos;
|
72
|
+
|
73
|
+
}
|
64
74
|
|
65
75
|
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
Debug.DrawRay(touchPointToRay.origin, touchPointToRay.direction * 1000.0f);
|
70
|
-
|
71
|
-
|
72
76
|
|
73
77
|
if (Input.GetKeyDown(KeyCode.S))
|
74
78
|
|
75
79
|
{
|
76
80
|
|
77
|
-
GetComponent<
|
81
|
+
//Light.GetComponent<Rigidbody>();
|
82
|
+
|
83
|
+
//m_Rigidbody.constraints = RigidbodyConstraints.FreezeAll;
|
78
84
|
|
79
85
|
}
|
80
86
|
|
81
87
|
}
|
82
88
|
|
83
89
|
}
|
84
|
-
|
85
|
-
|
86
90
|
|
87
91
|
### 試したこと
|
88
92
|
|