Unity/John Lemon in Nightmareland

Unity Piscine Module06 - 7. 열쇠 수집 / 엔딩 애니메이션 구현

surkim 2024. 8. 27. 13:00

열쇠 3개를 방에 랜덤 배치하고 3개를 먹은 후 엔딩방에 도달하면 문이열리도록 구현했다.

엔딩 애니메이션 페이드 인/아웃과 적에게 잡혔을 때의 애니메이션도 추가!

열쇠 랜덤 생성

 

public class KeyGenerator : MonoBehaviour
{
    [SerializeField] private GameObject keyPrefab;
    [SerializeField] private Transform[] spawnPoints;
    [SerializeField] private int numberOfKeys = 3;
    private bool[] check;

    void Start()
    {
        check = new bool[spawnPoints.Length];
        while (numberOfKeys > 0)
        {
            int index = Random.Range(0, spawnPoints.Length);
            if (!check[index])
            {
                check[index] = true;
                Instantiate(keyPrefab, spawnPoints[index].position, Quaternion.identity, transform);
                numberOfKeys--;
            }
        }
    }
}

 

 

인 게임 내 열쇠 모습

 

0
엔딩 애니메이션

 

어려운건 없었다.

이제 포스트 프로세싱에 대해 배워보고 적용해봐야지