컵 속으로
Coddy Unity 여정의 물리와 게임플레이 섹션에 포함된 레슨. 71개 중 69번째.
챌린지
어려움느린 구슬이 컵에 들어가게 하세요.
Hole에void OnTriggerEnter(Collider other)를 추가하세요.other.TryGetComponent(out Golf golf)이고other.attachedRigidbody.linearVelocity.magnitude < sinkSpeed이면"In the cup in " + golf.strokes + " strokes!"를 로그에 출력하고other.gameObject.SetActive(false);를 호출하세요.
‘플레이’를 누르고 구슬을 컵에 넣으세요. 빠른 구슬은 컵을 지나쳐 굴러갑니다. 그런 다음 ‘확인’을 누르세요.
직접 해보기
using UnityEngine;
public class Hole : MonoBehaviour
{
[SerializeField] private float sinkSpeed = 3f;
// 느린 구슬은 컵 안으로 떨어지고, 빠른 구슬은 그 위를 굴러 지나간다
}
물리와 게임플레이의 모든 레슨
직접 연습해 보세요: Unity 플레이그라운드