
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
Square이 떨어져서 Balloon과 충돌 했을 때, Balloon이 터지는 연출이 나와야하는데
게임을 실행하면 터지는 연출이 반복됩니다.

코드에는 문제가 없을거 같다고 생각이 들어서 Animation에서

Balloon_Die를 다시 설정해야하나 생각만하고 있는데 이 접근이 맞을까요?
[GameManager]
sing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public static GameManager Instance; // 나 혼자야
public GameObject square; // 박스안에 프리팹을 가져올 수 잇음
public GameObject endPanel;
public Text timeTxt;
public Text nowScore;
public Text bestScore;
public Animator anim;
bool isPlay = true;
float time = 0.0f;
string key = "bestScore";
private void Awake()
{
if(Instance == null)
{
Instance = this; // 싱글톤 완성
}
}
void Start()
{
Time.timeScale = 1.0f;
InvokeRepeating("MakeSquare", 0f, 1f); // 1초마다 Square Prefabs이 반복적으로 생성됩니ㅏㄷ.
}
void Update()
{
if (isPlay)
{
time += Time.deltaTime;
timeTxt.text = time.ToString("N2"); // float기에 string으로 변환
}
}
void MakeSquare()
{
Instantiate(square);
}
public void GameOver()
{
isPlay = false;
anim.SetBool("isDie", true);
Invoke("TimeStop", 0.5f);
nowScore.text = time.ToString("N2");
//최고점수가 있다면
if (PlayerPrefs.HasKey(key))
{
float best = PlayerPrefs.GetFloat(key);
// 최고점수 < 현재점수
if(best < time)
{
// 현재 점수를 최고점수에 저장한다.
PlayerPrefs.SetFloat(key,time);
bestScore.text = time.ToString("N2");
}
else
{
bestScore.text = best.ToString("N2");
}
}
else
{
PlayerPrefs.SetFloat(key,time);
bestScore.text = time.ToString("N2");
}
//최고점수가 없다면
// 현재 점수를 저장한다.
endPanel.SetActive(true);
}
void TimeStop()
{
Time.timeScale = 0.0f;
}
}
