2D 콘텐츠 제작

Geometry Dash [#7] - 마지막 조정

송현호 2023. 9. 21. 09:52

스테이지를 만들고 나서 게임을 하다보니 우주선으로 변신하고 다시 큐브로 돌아오는 상황에서 카메라가 원래 위치로 돌아오지 않는다는 걸 깨달았다. 그래서 마지막 시간의 클리어 연출을 스킵하고 카메라 조정과 파티클을 붙이는데 시간을 써야 할 것 같다.

 

1. 파티클

 

먼저 저번에 다 하지못한 파티클을 수정해주었다. 

처음엔 파티클을 캐릭터의 자식 오브젝트로 두고 필요할때 Play() 필요하지 않은 상황일때 Stop()함수를 이용해서 정지하는 식으로 해봤는데 캐릭터가 점프 할때 회전하면서 파티클도 같이 회전하는 문제가 발생했다. 그래서 파티클을 프리펩화 한다음 자식오브젝트에서 제거하고 캐릭터가 땅과 접촉 상태일때 파티클을 0.2초 동안 생성하는 식으로 바꾸었다. 

그리고 파티클에 size over lifetime 컴포넌트를 추가하고 random between two constant로 설정해서 파티클의 크기가 0부터 1사이로 랜덤하게 생성되도록 만들어 주었다.

 

private void OnCollisionStay2D(Collision2D collision)
    {
        Vector3 pos = new Vector3(this.transform.position.x+0.2f, this.transform.position.y - 0.3f, this.transform.position.z);
        GameObject go = Instantiate(grParticle,pos,grParticle.transform.rotation);
        Destroy(go, 0.2f);
    }

 

 

2. 카메라 조정

 

위에서 서술하였듯 우주선에서 큐브로 돌아올때 카메라의 위치가 위로 올라간 상태에서 돌아오지 않는다는 문제점이 있었다. 

 

그래서 스크립트에서 시네마신의 버추얼 카메라의 컴포넌트에 접근해서 Screen Y값을 약간 조정해주었다.

 

virCam.GetCinemachineComponent<CinemachineFramingTransposer>().m_ScreenY = 0.4f;

 

3. 클리어 씬 추가

 

그리고 간단하지만 비동기 방식을 이용해서 스테이지 클리어씬도 만들어주었다.

 

 

4. 루프 기능 추가

 

void Update()
    {
        if(hasPlayed == false && ch.transform.position.x > -9.28f)
        {
            audioSource.Play();
            hasPlayed = true;
        }
        if(hasPlayed == true)
        {
            this.elapsedTime += Time.deltaTime;
            this.elapsedTimeText.text = elapsedTime.ToString();
        }

        if (this.ch.activeSelf == false && isChDie == false)
        {
            StartCoroutine(CoRoof());
        }
    }

    private IEnumerator CoRoof()
    {
        isChDie = true;
        GameObject go = Instantiate(dieParticle, this.ch.transform.position, dieParticle.transform.rotation);
        Destroy(go, 0.5f);
        audioSource.Stop();
        yield return new WaitForSeconds(0.5f);
        onResetPosition();
        this.ch.transform.position = new Vector3(-13, -1.55f, 0);
        this.ch.SetActive(true);
        hasPlayed = false;
        isChDie = false;

    }

장애물과 만나서 캐릭터가 비활성화 될 경우 파티클을 방출하고 원래 위치로 돌아간 뒤 음악을 다시 재생하도록 만들었다.

 

파괴시 방출하는 파티클도 만들어주었다.