Przeglądaj źródła

修复瞄准空处的bug

lvjincheng 4 lat temu
rodzic
commit
37c7c3d472
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      Assets/BowArrow/Scripts/Game/Arrow.cs

+ 1 - 1
Assets/BowArrow/Scripts/Game/Arrow.cs

@@ -29,7 +29,7 @@ public class Arrow : MonoBehaviour
         } 
 
         //瞄准靶子发射时,自动调整仰角
-        if (raycastHit.transform.gameObject.name == "TargetBody") {
+        if (raycastHit.transform && raycastHit.transform.gameObject.name == "TargetBody") {
             ApplyParabolaAngle(raycastHit.point);            
             float distance = TargetBody.ins.GetDistance();
             if (Mathf.RoundToInt(distance) >= 50) {