using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{
    public PlayerController player;
    public float offsetX = 5, offsetY = 2, offsetZ = -10;
    public float lerpValue = 0.02f;

    [HideInInspector]
    public Vector3 targetPos;

    private void FixedUpdate()
    {
        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);
        }

        transform.position = Vector3.Lerp(transform.position, targetPos, lerpValue * Time.deltaTime);
    }
}
