質問編集履歴
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,6 +27,10 @@
|
|
27
27
|
|
28
28
|
|
29
29
|
public class NetAttack : NetworkBehaviour {
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
public GameObject netbullet;
|
30
34
|
|
31
35
|
|
32
36
|
|
1
追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Unity UNET
|
1
|
+
Unity UNET 弾の同期処理
|
test
CHANGED
@@ -11,6 +11,10 @@
|
|
11
11
|
以前、Command処理をしているものはOnClick()で呼び出せないと聞いたのでこのようにいたしました。
|
12
12
|
|
13
13
|
ご教授いただけると幸いです。よろしくお願いいたします。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
12/28追記いたしました。以下のコードのSpawn処理を追記致しました。
|
14
18
|
|
15
19
|
```
|
16
20
|
|
@@ -52,12 +56,38 @@
|
|
52
56
|
|
53
57
|
////ここに弾のSpawn処理と前に飛ばす処理を書く
|
54
58
|
|
55
|
-
|
56
59
|
|
60
|
+
|
61
|
+
GameObject obj = Instantiate<GameObject>(
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
netbullet,
|
66
|
+
|
67
|
+
this.transform.position,
|
68
|
+
|
69
|
+
this.transform.rotation
|
70
|
+
|
57
|
-
|
71
|
+
);
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
obj.transform.position = transform.GetChild(19).gameObject.transform.position;
|
58
76
|
|
59
77
|
|
60
78
|
|
61
79
|
|
62
80
|
|
81
|
+
obj.GetComponent<Rigidbody>().velocity = transform.forward * bulletspeed;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
NetworkServer.Spawn(obj);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
Destroy(obj, 4);
|
90
|
+
|
91
|
+
|
92
|
+
|
63
|
-
|
93
|
+
}
|