노트 최적화

오버랩은 레이어 마스크로 지정된 Collider를 찾는 메서드이다. IsTrigger를 사용할 경우, 노트가 너무 빠르면 감지가 안되는 경우가 있기 때문에 최적화를 위해  처음엔 RigidBody 대신 오버랩(Overlap)을 사용하려했다.

그런데 아예 노트와 노트 판정하는 위치의Transform 값을 받아와서 비교하면  Collider를 사용하지 않고 할 수 있었다.

 

노트를 리스트에 추가하기 위해 TimingManager 스크립트와 GetComponent로 연결하는데 연결이 되지 않고 null 값이 떴다. GetComponent는 자기 자신을 가져오는데 Note 스크립트와 TimingManager 스크립트가 같은 오브젝트에 있지 않았기 때문이었다.

Find 메서드를 사용하여 해결하였다.

public class Note : MonoBehaviour
{
    [SerializeField] private NoteMove noteMove;
    public KeyCode key;
    private Color color;
    TimingManager timingManager;
   

    private void Awake()
    {
        color = GetComponent<SpriteRenderer>().color;
        timingManager = FindObjectOfType<TimingManager>();

    }

    public void NoteCreate()
    {
        NoteMove note = Instantiate(noteMove, transform.position, Quaternion.identity);
        note.GetComponent<SpriteRenderer>().color = color;
        note.noteSpeed = PlaySetting.speed;
        
        timingManager.boxNoteList.Add(note.gameObject);
    }
}

 

트러블 슈팅

게임 플레이 도중 일시정지하거나 재시작 하는 기능을 추가하기로 했는데 노래 선택해서 플레이 하면서 일시정지 후, 게임을 나갔다가 다시 들어오면 게임 플레이 화면이 로딩되지 않는 현상이 있었다.

일시정지 기능을 Time.timeScale = 0으로 구현했는데 그 후에 다시 시간이 흐르도록 처리하지 않아서 생긴 문제였다.

 

+ Recent posts