45. 弾丸の実装
同期スクリプト: クラス名変更
• BulletNetwork.csを編集していることを確認
• 3行目のクラス名を
BulletNetwork
に変更
45
Before
3:public class NetworkCharacter : Photon.MonoBehaviour
After
3:public class BulletNetwork : Photon.MonoBehaviour
46. 弾丸の実装
同期スクリプト: 物理挙動制御
• 6-7行目の間に
‘Sample Code A-2’
の6行をコピー&ペーストで追加-> Awake()メソッド追加
46
Before
6:private Quaternion correctPlayerRot = Quaternion.identity; // We lerp towards this
7:// Update is called once per frame
8:void Update()
After
6:private Quaternion correctPlayerRot = Quaternion.identity; // We lerp towards this
+ 7:void Awake()
+ 8:{
+ 9: if (photonView.isMine) {
+10: rigidbody.isKinematic = false;
+11: }
+12:}
13:// Update is called once per frame
14:void Update()
47. 弾丸の実装
同期スクリプト: 不要コード削除1
• OnPhotonSerializeView()メソッド内の31-32行目を削除
(Sample Code A-3)
47
Before
27: // We own this player: send the others our data
28: stream.SendNext(transform.position);
29: stream.SendNext(transform.rotation);
30:
-31: myThirdPersonController myC = GetComponent<myThirdPersonController>();
-32: stream.SendNext((int)myC._characterState);
33:}
After
27: // We own this player: send the others our data
28: stream.SendNext(transform.position);
29: stream.SendNext(transform.rotation);
30:
33:}
60. モンスターの設定
同期スクリプト: スクリプト制御
• 6-7行目の間に
‘Sample Code C-1’
の7行をコピー&ペーストで追加-> Awake()メソッド追加
60
Before
6:private Quaternion correctPlayerRot = Quaternion.identity; // We lerp towards this
7:// Update is called once per frame
8:void Update()
After
6:private Quaternion correctPlayerRot = Quaternion.identity; // We lerp towards this
+ 7:void Awake()
+ 8:{
+ 9: if (photonView.isMine) {
+10: GetComponent<ThirdPersonCamera>().enabled = true;
+11: GetComponent<MonsterFire>().enabled = true;
+12: }
+13:}
14:// Update is called once per frame