回答編集履歴
2
不要な括弧を削除した
test
CHANGED
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
{
|
78
78
|
|
79
|
-
Vector3 diff =
|
79
|
+
Vector3 diff = center.transform.position - obj.transform.position;
|
80
80
|
|
81
81
|
obj.transform.rotation = Quaternion.FromToRotation(Vector3.up, diff);
|
82
82
|
|
1
LookAt に対応した
test
CHANGED
@@ -56,7 +56,9 @@
|
|
56
56
|
|
57
57
|
/// <param name="distance">距離</param>
|
58
58
|
|
59
|
+
/// /// <param name="isLookAtCenter">中心点の方向に向けるか</param>
|
60
|
+
|
59
|
-
private void SpawnObjectsOnRoundTable(GameObject prefab, int count, GameObject center, float distance)
|
61
|
+
private void SpawnObjectsOnRoundTable(GameObject prefab, int count, GameObject center, float distance, bool isLookAtCenter = true)
|
60
62
|
|
61
63
|
{
|
62
64
|
|
@@ -67,6 +69,18 @@
|
|
67
69
|
var position = center.transform.position + (Quaternion.Euler(0f, 0f, 360f / count * i) * center.transform.up * distance);
|
68
70
|
|
69
71
|
var obj = Instantiate(prefab, position, Quaternion.identity);
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
if (isLookAtCenter)
|
76
|
+
|
77
|
+
{
|
78
|
+
|
79
|
+
Vector3 diff = (center.transform.position - obj.transform.position);
|
80
|
+
|
81
|
+
obj.transform.rotation = Quaternion.FromToRotation(Vector3.up, diff);
|
82
|
+
|
83
|
+
}
|
70
84
|
|
71
85
|
}
|
72
86
|
|
@@ -80,4 +94,4 @@
|
|
80
94
|
|
81
95
|
**実行している様子**
|
82
96
|
|
83
|
-
![イメージ説明](
|
97
|
+
![イメージ説明](dde35b814295dac293d39247902bf957.gif)
|