Эх сурвалжийг харах

摄像机放大视野改为修改Z轴

LAPTOP-OM1V99U2\永远de小亡灵 1 жил өмнө
parent
commit
1d74963d25

+ 0 - 11
ActionTowerDefense/Assets/Resources/Actions/Player.inputactions

@@ -211,17 +211,6 @@
                     "isComposite": false,
                     "isPartOfComposite": false
                 },
-                {
-                    "name": "",
-                    "id": "4609900e-d831-42a3-9d32-956209603918",
-                    "path": "<Gamepad>/leftStick/up",
-                    "interactions": "",
-                    "processors": "",
-                    "groups": "",
-                    "action": "Jump",
-                    "isComposite": false,
-                    "isPartOfComposite": false
-                },
                 {
                     "name": "",
                     "id": "a2b23a0b-9659-446c-8eec-bc8672be18f7",

+ 6 - 6
ActionTowerDefense/Assets/Scenes/SampleScene.unity

@@ -714,7 +714,7 @@ Transform:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 519420028}
   m_LocalRotation: {x: -0.06828801, y: -0, z: -0, w: 0.9976657}
-  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalPosition: {x: 0, y: 3, z: -16}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
@@ -1038,19 +1038,19 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 584ea0f557c97344f9b229261554243d, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  offsetX: 0
+  offsetX: 6
   offsetY: 3
   offsetZ: -16
   lerpValue: 3.5
   targetPos: {x: 0, y: 0, z: 0}
   leftTargetPos: {x: 0, y: 0, z: 0}
   rightTargetPos: {x: 0, y: 0, z: 0}
+  cameraPos: {x: 0, y: 0, z: 0}
   mainCamera: {fileID: 519420031}
   leftCamera: {fileID: 815407867}
   rightCamera: {fileID: 850878590}
-  minField: 55
-  maxField: 80
-  field: 0
+  maxView: 8
+  view: 0
   minDistance: 20
   splitDistance: 30
   mergeDistance: 16
@@ -1066,7 +1066,7 @@ Transform:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 1055802828}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
-  m_LocalPosition: {x: 0, y: 3.5, z: -18}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children:

+ 36 - 10
ActionTowerDefense/Assets/Scripts/CameraController.cs

@@ -13,15 +13,16 @@ public class CameraController : MonoBehaviour
     public Vector3 leftTargetPos;
     [HideInInspector]
     public Vector3 rightTargetPos;
+    [HideInInspector]
+    public Vector3 cameraPos;
 
     public Camera mainCamera;
     public Camera leftCamera;
     public Camera rightCamera;
 
-    public float minField = 55;
-    public float maxField = 75;
+    public float maxView = 20;
     [HideInInspector]
-    public float field;
+    public float view;
     public float minDistance = 20;
     public float splitDistance = 30;
     public float mergeDistance = 16;
@@ -37,10 +38,14 @@ public class CameraController : MonoBehaviour
 
     private void Start()
     {
-        ratio = (maxField - minField) / (splitDistance - minDistance);
+        //ratio = maxView / (splitDistance - minDistance);
     }
     private void Update()
     {
+        //µ÷²ÎÓÃ
+        ratio = maxView / (splitDistance - minDistance);
+        //
+
         if (PlayersInput.instance[0] == null)
         {
             targetPos = Vector3.zero + new Vector3(0, offsetY, offsetZ);
@@ -66,14 +71,22 @@ public class CameraController : MonoBehaviour
                 rightTargetPos = CameraTargetMove(PlayersInput.instance[0]);
 
             }
-            targetPos = Vector3.Lerp(leftCamera.transform.position, rightCamera.transform.position, 0.5f);
-            field = Mathf.Clamp(minField + (distance - minDistance) * ratio, minField, maxField);
+
+            view = Mathf.Clamp((distance - minDistance) * ratio, 0, maxView);
             if (distance < mergeDistance)
             {
                 mainCamera.enabled = true;
                 leftCamera.enabled = false;
                 rightCamera.enabled = false;
                 lineInCamera.SetActive(false);
+
+            }
+            else
+            {
+                lineInCamera.transform.localScale = new Vector3(Mathf.Clamp(
+                    (distance - mergeDistance) * 0.01f, 0, lineMaxScale), 10, 1);
+                targetPos =
+                    Vector3.Lerp(leftCamera.transform.position, rightCamera.transform.position, 0.5f);
             }
             if (distance > splitDistance)
             {
@@ -81,8 +94,12 @@ public class CameraController : MonoBehaviour
                 leftCamera.enabled = true;
                 rightCamera.enabled = true;
                 lineInCamera.SetActive(true);
-                lineInCamera.transform.localScale = new Vector3(Mathf.Clamp(
-                    (distance - mergeDistance) * 0.01f, 0, lineMaxScale), 10, 1);
+
+            }
+            else
+            {
+                targetPos =
+                    Vector3.Lerp(player0Pos, player1Pos, 0.5f) + new Vector3(0, offsetY, offsetZ);
             }
 
         }
@@ -96,12 +113,21 @@ public class CameraController : MonoBehaviour
         }
         else
         {
-            mainCamera.transform.position = targetPos;
+            if (lineInCamera.activeSelf)
+            {
+                cameraPos = targetPos;
+            }
+            else
+            {
+                cameraPos = Vector3.Lerp(mainCamera.transform.position,
+                    targetPos, lerpValue * Time.deltaTime);
+            }
+
+            mainCamera.transform.position = new Vector3(cameraPos.x, cameraPos.y,offsetZ - view);
             leftCamera.transform.position = Vector3.Lerp(leftCamera.transform.position,
                 leftTargetPos, lerpValue * Time.deltaTime);
             rightCamera.transform.position = Vector3.Lerp(rightCamera.transform.position,
                 rightTargetPos, lerpValue * Time.deltaTime);
-            mainCamera.fieldOfView = field;
 
         }