빠른 비교
// 일시정지
Time.timeScale = 0f;
// 재개
Time.timeScale = 1f;
// 슬로모션
Time.timeScale = 0.3f;
// pause 중에도 계속 도는 UI 타이머
pauseTimer += Time.unscaledDeltaTime;
// pause 중에도 기다리는 코루틴
yield return new WaitForSecondsRealtime(1f);갈리는 기준
timeScale이 영향을 주는 것들
Time.timeScale은 게임 세계의 시간 흐름 전체를 느리게 하거나 멈추는 전역 배율입니다. 기본값은 1이며, 0이면 완전 정지, 0.5면 절반 속도, 2면 두 배 속도입니다.
영향을 받는 것: Time.deltaTime, Time.fixedDeltaTime, WaitForSeconds, 물리 시뮬레이션, Animator(updateMode가 기본값인 경우)
영향을 받지 않는 것: Time.unscaledDeltaTime, Time.unscaledTime, WaitForSecondsRealtime, AudioSource 재생 속도(별도 설정 필요)
일시정지 구현
timeScale = 0으로 게임을 멈출 때, 메뉴·페이드·로딩 UI는 계속 돌아야 합니다. 이 UI들은 unscaled 계열을 써야 합니다.
public void Pause()
{
Time.timeScale = 0f;
pauseMenuPanel.SetActive(true);
}
public void Resume()
{
Time.timeScale = 1f;
pauseMenuPanel.SetActive(false);
}
// pause 메뉴의 카운트다운 — unscaled 사용
private void Update()
{
if (isPaused)
countdownDisplay.text = FormatTime(countdownTimer -= Time.unscaledDeltaTime);
}슬로모션 구현
timeScale을 서서히 낮추면 슬로모션 연출을 만들 수 있습니다. fixedDeltaTime도 함께 조정하면 물리 정밀도를 유지할 수 있습니다.
public void TriggerSlowMotion(float targetScale, float duration)
{
StartCoroutine(SlowMotionRoutine(targetScale, duration));
}
private IEnumerator SlowMotionRoutine(float targetScale, float duration)
{
Time.timeScale = targetScale;
Time.fixedDeltaTime = 0.02f * Time.timeScale; // 물리 정밀도 유지
yield return new WaitForSecondsRealtime(duration); // 실제 시간 기준 대기
Time.timeScale = 1f;
Time.fixedDeltaTime = 0.02f;
}WaitForSeconds vs WaitForSecondsRealtime
코루틴에서도 timeScale 영향이 그대로 적용됩니다.
// timeScale = 0이면 영원히 기다림 (게임 멈춤 중엔 사용 불가)
yield return new WaitForSeconds(1f);
// timeScale과 무관하게 실제 1초 후 재개
yield return new WaitForSecondsRealtime(1f);pause 중에 동작하는 연출(메뉴 전환 애니메이션, 재개 카운트다운)은 반드시 WaitForSecondsRealtime을 써야 합니다.
선택 기준
| 항목 | timeScale 영향 | 적합한 용도 |
|---|---|---|
Time.deltaTime | 받음 | 게임플레이 이동, 로직 |
Time.unscaledDeltaTime | 받지 않음 | pause UI, 메뉴 타이머 |
Time.fixedDeltaTime | 받음 | 물리 루프 |
WaitForSeconds | 받음 | 게임플레이 코루틴 |
WaitForSecondsRealtime | 받지 않음 | pause 중 코루틴, 메뉴 연출 |
Time.time | 받음 | 게임 내 경과 시간 |
Time.realtimeSinceStartup | 받지 않음 | 앱 실행 이후 실제 시간 |
| 상황 | 선택 |
|---|---|
| 게임플레이 타이머, 이동 | deltaTime / WaitForSeconds |
| pause 중 UI, 카운트다운 | unscaledDeltaTime / WaitForSecondsRealtime |
| 슬로모션 물리 정밀도 | fixedDeltaTime = 0.02f * timeScale |
| 비교 | 더 잘 맞는 쪽 | 이유 |
|---|---|---|
| 게임 세계 시간 vs UI 시간 | scaled / unscaled | pause와 슬로모션에서 흐름을 분리해야 함 |
| gameplay coroutine vs pause UI coroutine | WaitForSeconds / WaitForSecondsRealtime | timeScale 영향 여부가 다름 |
| timeScale만 변경 vs fixedDeltaTime도 조정 | 둘 다 조정 | 물리 정밀도와 체감이 달라짐 |
주의할 점
timeScale = 0을 걸었을 때 모든 타이머, 코루틴, UI가 왜 멈춰 있는지 뒤늦게 발견하는 것이 가장 흔한 실수입니다. 설계 초반에 "이 시스템은 pause 중에도 돌아야 하는가?"를 먼저 분리하세요. 메뉴 애니메이션, 재개 카운트다운, 네트워크 timeout, 툴팁 지연은 대부분 unscaled 계열이어야 합니다. fixedDeltaTime을 0.02f * timeScale로 함께 조정하지 않으면 슬로모션 중 물리 시뮬레이션 정밀도가 떨어질 수 있습니다.
// ❌ 슬로모션인데 fixedDeltaTime은 그대로 둠
Time.timeScale = 0.2f;
// → 물리 반응이 의도보다 거칠거나 불규칙하게 느껴질 수 있음
// ✅ 물리 timestep도 같이 조정
Time.timeScale = 0.2f;
Time.fixedDeltaTime = 0.02f * Time.timeScale;참고 링크
3 sources