質問編集履歴
5
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,15 +56,15 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
if (Input.GetButtonDown("Fire3"))
|
60
|
-
|
61
|
-
{
|
62
|
-
|
63
59
|
//1フレーム前と現在の座標の差を、enhancementの値で乗算
|
64
60
|
|
65
61
|
Vector3 enhancedMovement = Movement * enhancement;
|
66
62
|
|
67
63
|
|
64
|
+
|
65
|
+
if (Input.GetButtonDown("Fire3"))
|
66
|
+
|
67
|
+
{
|
68
68
|
|
69
69
|
//rockプレハブをhandの位置から射出
|
70
70
|
|
4
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,6 +48,8 @@
|
|
48
48
|
|
49
49
|
{
|
50
50
|
|
51
|
+
//1フレーム前と現在の座標の差を算出
|
52
|
+
|
51
53
|
Vector3 PlayerPosition = this.transform.position;
|
52
54
|
|
53
55
|
Vector3 Movement = PlayerPosition - lastPos;
|
@@ -58,9 +60,13 @@
|
|
58
60
|
|
59
61
|
{
|
60
62
|
|
63
|
+
//1フレーム前と現在の座標の差を、enhancementの値で乗算
|
64
|
+
|
61
65
|
Vector3 enhancedMovement = Movement * enhancement;
|
62
66
|
|
63
67
|
|
68
|
+
|
69
|
+
//rockプレハブをhandの位置から射出
|
64
70
|
|
65
71
|
GameObject rocks = Instantiate(rock) as GameObject;
|
66
72
|
|
3
コードの間違い等を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,56 +18,60 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
public class throwing : MonoBehaviour
|
22
|
+
|
23
|
+
{
|
24
|
+
|
25
|
+
Vector3 PlayerPosition;
|
26
|
+
|
27
|
+
Vector3 lastPos;
|
28
|
+
|
29
|
+
Vector3 Movement;
|
30
|
+
|
31
|
+
Vector3 enhancedMovement;
|
32
|
+
|
33
|
+
public float enhancement;
|
34
|
+
|
35
|
+
public GameObject rock;
|
36
|
+
|
37
|
+
GameObject rocks;
|
38
|
+
|
39
|
+
public GameObject hand;
|
40
|
+
|
41
|
+
Vector3 Force;
|
42
|
+
|
43
|
+
public Vector3 presetForce;
|
44
|
+
|
21
45
|
|
22
46
|
|
23
47
|
void Update()
|
24
48
|
|
25
49
|
{
|
26
50
|
|
27
|
-
|
51
|
+
Vector3 PlayerPosition = this.transform.position;
|
28
52
|
|
29
|
-
{
|
30
|
-
|
31
|
-
//操作キャラの現在の座標
|
32
|
-
|
33
|
-
|
53
|
+
Vector3 Movement = PlayerPosition - lastPos;
|
34
54
|
|
35
55
|
|
36
56
|
|
37
|
-
|
57
|
+
if (Input.GetButtonDown("Fire3"))
|
38
58
|
|
59
|
+
{
|
60
|
+
|
39
|
-
|
61
|
+
Vector3 enhancedMovement = Movement * enhancement;
|
40
62
|
|
41
63
|
|
42
64
|
|
43
|
-
|
65
|
+
GameObject rocks = Instantiate(rock) as GameObject;
|
44
66
|
|
45
|
-
|
67
|
+
rocks.transform.position = hand.transform.position;
|
46
68
|
|
69
|
+
Vector3 Force = presetForce + enhancedMovement;
|
47
70
|
|
71
|
+
rocks.GetComponent<Rigidbody>().AddForce(Force);
|
48
72
|
|
49
|
-
|
73
|
+
}
|
50
74
|
|
51
|
-
|
75
|
+
}
|
52
76
|
|
53
|
-
|
54
|
-
|
55
|
-
// 発射位置を“hand”(インスペクターでオブジェクト指定)に調整
|
56
|
-
|
57
|
-
rocks.transform.position = hand.position;
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
//インスペクターで設定した発射威力(presetForce)に、enhancedMovementを加算
|
62
|
-
|
63
|
-
Vector3 Force = presetForce + enhancedMovement;
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
// Rigidbodyのaddforceで発射
|
68
|
-
|
69
|
-
rocks.GetComponent<Rigidbody>().AddForce(Force);
|
70
|
-
|
71
|
-
|
77
|
+
}
|
72
|
-
|
73
|
-
}
|
2
コードの間違い修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
// 発射位置を“hand”(インスペクターでオブジェクト指定)に調整
|
56
56
|
|
57
|
-
|
57
|
+
rocks.transform.position = hand.position;
|
58
58
|
|
59
59
|
|
60
60
|
|
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
// Rigidbodyのaddforceで発射
|
68
68
|
|
69
|
-
|
69
|
+
rocks.GetComponent<Rigidbody>().AddForce(Force);
|
70
70
|
|
71
71
|
}
|
72
72
|
|
1
言い回し修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
そこで、1フレーム前の座標と現在の座標の差をaddforceの値に加算しようと思ったのですが、
|
10
10
|
|
11
|
-
むしろ
|
11
|
+
むしろ飛ぶ距離が縮むなど、上手くいきません。
|
12
12
|
|
13
13
|
改善方法を教えて頂けると嬉しいです。よろしくお願いします。
|
14
14
|
|