|
|
@@ -13,9 +13,11 @@ using UnityEngine;
|
|
|
|
|
|
public class CameraController : MonoBehaviour
|
|
|
{
|
|
|
- public float offsetX = 2, offsetY = 2, offsetZ = -17, offsetYDown = -10;
|
|
|
+ public float offsetX = 2, offsetY = 2, offsetZ = -17,totalOffsetYDown = -10;
|
|
|
public float lerpValue = 3.5f;
|
|
|
|
|
|
+ [HideInInspector]
|
|
|
+ public float offsetYDown;
|
|
|
[HideInInspector]
|
|
|
public Vector3 targetPos;
|
|
|
[HideInInspector]
|
|
|
@@ -47,7 +49,7 @@ public class CameraController : MonoBehaviour
|
|
|
public GameObject lineInCamera;
|
|
|
|
|
|
public bool isSplit;
|
|
|
- public bool isSplitY;
|
|
|
+ //public bool isSplitY;
|
|
|
|
|
|
public float minDis;
|
|
|
private int once;
|
|
|
@@ -64,6 +66,7 @@ public class CameraController : MonoBehaviour
|
|
|
private void Start()
|
|
|
{
|
|
|
ratio = maxView / (splitDistance - mergeDistanceX);
|
|
|
+ offsetYDown = totalOffsetYDown;
|
|
|
}
|
|
|
private void Update()
|
|
|
{
|
|
|
@@ -120,14 +123,16 @@ public class CameraController : MonoBehaviour
|
|
|
if (distanceY > mergeDistanceY)
|
|
|
{
|
|
|
view = (distanceY - mergeDistanceY) * ratioY;
|
|
|
- isSplitY = true;
|
|
|
+ //isSplitY = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (isSplitY)
|
|
|
- {
|
|
|
- isSplitY = false;
|
|
|
- }
|
|
|
+ //if (isSplitY)
|
|
|
+ //{
|
|
|
+ // isSplitY = false;
|
|
|
+ //}
|
|
|
+ offsetYDown = Mathf.Clamp(totalOffsetYDown /(2* mergeDistanceY) * distanceY,
|
|
|
+ totalOffsetYDown, 0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -164,15 +169,17 @@ public class CameraController : MonoBehaviour
|
|
|
if(viewX > viewY)
|
|
|
{
|
|
|
view = viewX;
|
|
|
- if (isSplitY)
|
|
|
- {
|
|
|
- isSplitY = false;
|
|
|
- }
|
|
|
+ //if (isSplitY)
|
|
|
+ //{
|
|
|
+ // isSplitY = false;
|
|
|
+ //}
|
|
|
+ offsetYDown = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
view = viewY;
|
|
|
- isSplitY = true;
|
|
|
+ //isSplitY = true;
|
|
|
+ offsetYDown = totalOffsetYDown;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -240,31 +247,22 @@ public class CameraController : MonoBehaviour
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- if (isSplitY)
|
|
|
+ if (player0TargetPos.y > player1TargetPos.y)
|
|
|
{
|
|
|
- if(player0TargetPos.y > player1TargetPos.y)
|
|
|
- {
|
|
|
- player0Camera.transform.position = Vector3.Lerp(player0Camera.transform.position,
|
|
|
- player0TargetPos + Vector3.up * offsetYDown, lerpValue * 2 * Time.deltaTime);
|
|
|
- player1Camera.transform.position = Vector3.Lerp(player1Camera.transform.position,
|
|
|
- player1TargetPos, lerpValue * 2 * Time.deltaTime);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- player0Camera.transform.position = Vector3.Lerp(player0Camera.transform.position,
|
|
|
- player0TargetPos, lerpValue * 2 * Time.deltaTime);
|
|
|
- player1Camera.transform.position = Vector3.Lerp(player1Camera.transform.position,
|
|
|
- player1TargetPos + Vector3.up * offsetYDown, lerpValue * 2 * Time.deltaTime);
|
|
|
- }
|
|
|
+ player0Camera.transform.position = Vector3.Lerp(player0Camera.transform.position,
|
|
|
+ player0TargetPos + Vector3.up * offsetYDown, lerpValue * 2 * Time.deltaTime);
|
|
|
+ player1Camera.transform.position = Vector3.Lerp(player1Camera.transform.position,
|
|
|
+ player1TargetPos, lerpValue * 2 * Time.deltaTime);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
player0Camera.transform.position = Vector3.Lerp(player0Camera.transform.position,
|
|
|
- player0TargetPos, lerpValue * 2 * Time.deltaTime);
|
|
|
+ player0TargetPos, lerpValue * 2 * Time.deltaTime);
|
|
|
player1Camera.transform.position = Vector3.Lerp(player1Camera.transform.position,
|
|
|
- player1TargetPos, lerpValue * 2 * Time.deltaTime);
|
|
|
+ player1TargetPos + Vector3.up * offsetYDown, lerpValue * 2 * Time.deltaTime);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
mainCamera.transform.position = Vector3.Lerp(player0Camera.transform.position,
|
|
|
player1Camera.transform.position, 0.5f) + Vector3.back * view;
|
|
|
}
|