Bladeren bron

镜头同步问题

lvjincheng 3 jaren geleden
bovenliggende
commit
77e10f7dce
1 gewijzigde bestanden met toevoegingen van 6 en 4 verwijderingen
  1. 6 4
      Assets/BowArrow/Scripts/Manager/GameMode/OnlineObject/ArrowSync.cs

+ 6 - 4
Assets/BowArrow/Scripts/Manager/GameMode/OnlineObject/ArrowSync.cs

@@ -60,6 +60,7 @@ public class ArrowSync : MonoBehaviour
     ArrowCamera arrowCameraComp;
 
     [System.NonSerialized] public bool isHit;
+    [System.NonSerialized] public bool hasDoneNextShoot;
     [System.NonSerialized] public bool canUseSideCamera;
     [System.NonSerialized] public bool hasSetSyncData = false; //外部运算用的
     public void SetSyncData(SyncData syncData, bool apply = false) {
@@ -73,15 +74,16 @@ public class ArrowSync : MonoBehaviour
         canUseSideCamera = syncData.cs;
         bool oldIsHit = isHit;
         isHit = syncData.ih;
+        hasDoneNextShoot = syncData.dns;
         mySpeed = syncData.sp;
         if (apply) {
             transform.position = position;
             transform.rotation = rotation;
-            if (!isHit) {
+            if (!isHit || !hasDoneNextShoot) {
                 //激活镜头
                 Transform cameraTF = this.transform.Find("Camera");
                 cameraTF.gameObject.SetActive(true);
-                ArrowCamera arrowCameraComp = cameraTF.gameObject.AddComponent<ArrowCamera>();
+                arrowCameraComp = cameraTF.gameObject.AddComponent<ArrowCamera>();
                 arrowCameraComp.SetArrowSync(this);
                 //射出的声音
                 AudioMgr.ins.PlayShoot(AudioMgr.GetAudioSource(this.gameObject));
@@ -96,8 +98,6 @@ public class ArrowSync : MonoBehaviour
             }
         } else {
             if (!oldIsHit && isHit) {
-                Transform cameraTF = this.transform.Find("Camera");
-                arrowCameraComp = cameraTF.gameObject.GetComponent<ArrowCamera>();
                 if (arrowCameraComp) {
                     if (arrowCameraComp.arrowCameraTemplate == null) {
                         isHit = false;
@@ -152,6 +152,7 @@ public class ArrowSync : MonoBehaviour
         public bool ih;
         public int ht;
         public float sp;
+        public bool dns; //hasDoneNextShoot
         public string act3; // ArrowCameraTemplate3
         public void SetData(Arrow arrow) {
             Quaternion r = arrow.transform.rotation;
@@ -167,6 +168,7 @@ public class ArrowSync : MonoBehaviour
             ih = arrow.isHit;
             ht = arrow.hitType;
             sp = arrow.mySpeed;
+            dns = arrow.hasDoneNextShoot;
             if (!inited) {
                 id = autoID++;
                 if (autoID > 1000) autoID = 0;