# 생각
캐릭터 이동에 따른 카메라 이동 조정
# 전체 코드
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraManager : MonoBehaviour
{
public GameObject target; // 카메라가 따라갈 대상
public float moveSpeed; // 카메라가 얼마나 빠른 속도로 움직이는지
private Vector3 targetPosition; // 대상의 현재 위치 값
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (target.gameObject != null)
{
targetPosition.Set(target.transform.position.x, target.transform.position.y, this.transform.position.z);
this.transform.position = Vector3.Lerp(this.transform.position, targetPosition, moveSpeed * Time.deltaTime); // 1초에 movespeed만큼이동
}
}
}
'Project > Project_Us' 카테고리의 다른 글
MovementController (0) | 2022.05.23 |
---|---|
AnimatedSpriteRenderer (0) | 2022.05.23 |