
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
게임을 클리어해서 끝을 눌르고 다시 시작을 하면 재대로 동작하는데
타임 오버로 끝을 누르고 다시 시작하면 timescale 값이 조정되지 않습니다.
일단 문제는 끝 버튼에 있는 TimeScale 조절을 게임매니저 스크립트의 start 함수에 옮겨서 고쳤습니다만
어째서 똑같은 함수를 실행하는데 왜 하나는 되고 하나는 안 되는지 이해가 안 가 질문 드립니다.
작성한 코드 및 에러 메세지
게임매니저 스크립트
void Update()
{
time += Time.deltaTime;
timeText.text = time.ToString("N2");
if (time >= 30)
{
EndGame();
}
}
public void Match()
{
if (firstCard.transform.Find("Front").GetComponent<SpriteRenderer>().sprite.name == secondCard.transform.Find("Front").GetComponent<SpriteRenderer>().sprite.name)
{
firstCard.GetComponent<Card>().Destroy();
secondCard.GetComponent<Card>().Destroy();
if (GameObject.Find("Cards").transform.childCount == 2)
{
EndGame();
}
}
else
{
firstCard.GetComponent<Card>().Close();
secondCard.GetComponent<Card>().Close();
}
firstCard = null;
secondCard = null;
}
void EndGame()
{
Time.timeScale = 0;
endText.gameObject.SetActive(true);
}
끝 버튼 스크립트
public void Restart()
{
Time.timeScale = 1;
SceneManager.LoadScene("MainScene");
}
}
