✅ 시간 촉박 경고 기능 로직 수정


📄 내용

→ 스크립트

public class Timer : MonoBehaviour
{
    public Text TimeTxt;
    public Animator TimeTxtAnim;
    public Color StartColor;
    public Color EndColor;

    private GameManager _gameManager; //게임매니저에 접근하기 위한 변수
    private Camera _mainCamera; //메인카메라
    private float _warningTime = 20.0f; //타이머 애니메이션 시작할 시간
    private float _warningBackground = **10.0f**; //배경 애니메이션 시작할 시간
    private float _colorChangeDuration = **5.0f**; //배경색 변경에 걸리는 시간

    void Start()
    {
        _gameManager = FindObjectOfType<GameManager>(); //게임매니저 찾기
        _mainCamera = Camera.main; //메인카메라 찾기
    }

    // Update is called once per frame
    void Update()
    {
        float time = _gameManager.GetTime(); //time에 시간 넣기

        if(time **<=** _warningTime)
        {
            TimeTxtAnim.enabled = true;
        }
        **else
        {
            TimeTxtAnim.enabled = false;
        }**

        //배경색 변경
        float t = Mathf.Clamp01(**(_warningBackground - time) / _colorChangeDuration**); //보간에 사용될 시간 값을 계산
        _mainCamera.backgroundColor = Color.Lerp(StartColor, EndColor, t);
    }
}

수정사항


💫Troubleshooting


📜 내용 정리

시간 촉박 기능 로직 수정 적용.mp4