속도 높이기
Coddy Unity 여정의 실제 게임 만들기 섹션에 포함된 레슨. 60개 중 29번째.
챌린지
중급GameManager에 속도를 저장하면서 도로의 속도를 높이세요.
GameManager에public static GameManager Instance;를 추가하고,Awake()에서Instance = this;로 설정하세요.Update()에서 다음을 추가하세요:speed = Mathf.Min(speed + speedUp * Time.deltaTime, maxSpeed);.Obstacle에서speed필드를 삭제하고 매 프레임 읽어오는GameManager.Instance.speed를 사용해 이동하게 하세요.
‘플레이’를 누르세요. 장애물이 점점 더 빠르게 다가옵니다. 그런 다음 ‘확인’을 누르세요.
직접 해보기
using UnityEngine;
public class GameManager : MonoBehaviour
{
public float speed = 10f;
public float speedUp = 0.5f;
public float maxSpeed = 20f;
// 이것을 싱글턴으로 만들고 매 프레임마다 도로의 속도를 높이세요
}
실제 게임 만들기의 모든 레슨
직접 연습해 보세요: Unity 플레이그라운드