|
@@ -4,7 +4,6 @@ using UnityEngine;
|
|
|
|
|
|
|
|
public class CameraController : MonoBehaviour
|
|
public class CameraController : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
- public PlayerController player;
|
|
|
|
|
public float offsetX = 5, offsetY = 2, offsetZ = -10;
|
|
public float offsetX = 5, offsetY = 2, offsetZ = -10;
|
|
|
public float lerpValue = 0.02f;
|
|
public float lerpValue = 0.02f;
|
|
|
|
|
|
|
@@ -13,15 +12,33 @@ public class CameraController : MonoBehaviour
|
|
|
|
|
|
|
|
private void FixedUpdate()
|
|
private void FixedUpdate()
|
|
|
{
|
|
{
|
|
|
- if (player.bodyTrans.localScale.x > 0)
|
|
|
|
|
|
|
+ if (PlayersInput.instance[0] == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ targetPos = Vector3.zero + new Vector3(0, offsetY, offsetZ);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(PlayersInput.instance[1] == null)
|
|
|
{
|
|
{
|
|
|
- targetPos = player.transform.position + new Vector3 (-offsetX, offsetY, offsetZ);
|
|
|
|
|
|
|
+ targetPos = CameraTargetMove(PlayersInput.instance[0]);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- targetPos = player.transform.position + new Vector3(offsetX, offsetY, offsetZ);
|
|
|
|
|
|
|
+ targetPos = Vector3.Lerp(PlayersInput.instance[0].transform.position,
|
|
|
|
|
+ PlayersInput.instance[1].transform.position, 0.5f) + new Vector3(0,offsetY,offsetZ);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
transform.position = Vector3.Lerp(transform.position, targetPos, lerpValue * Time.deltaTime);
|
|
transform.position = Vector3.Lerp(transform.position, targetPos, lerpValue * Time.deltaTime);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ Vector3 CameraTargetMove(PlayerController player)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (player.bodyTrans.localScale.x > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ targetPos = player.transform.position + new Vector3(-offsetX, offsetY, offsetZ);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ targetPos = player.transform.position + new Vector3(offsetX, offsetY, offsetZ);
|
|
|
|
|
+ }
|
|
|
|
|
+ return targetPos;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|