3-3) Creating Smooth Following Camera

시그니천·2024년 6월 5일

[ G01 ] ZigZagRacer

목록 보기
11/26

1. CameraFollow

public class CameraFollow : MonoBehaviour
{
    [SerializeField] private Transform target;

    private Vector3 distance;
    [SerializeField] private float smoothValue;

    private void Start()
    {
        distance = target.position - transform.position;
    }

    private void Update()
    {
        Follow();
    }

    void Follow()
    {
        Vector3 currentPos = transform.position;

        Vector3 targetPos = target.position - distance;

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

2. 셋팅해주기

  • player 셋팅
  • Smoothvalue 셋팅

3. 카메라 설정

  • MainCamera > Camera > Projection > Cliiping Planes > Near값조정
  • -5정도?
profile
우주최강개발자

0개의 댓글