
판넬 넣고 종료함수 다 넣었는데용
플레이 눌렀는데 시간 가긴 가는데
풍선이랑 네모랑 부딪혔는데도 게임 종료가 안되고 있습니다.
그리고 네모들이 너무 많이 떨어지는데 좀 천천히 내려올 수 있게 할 수 있나요?ㅜ
첫번째 코드는 게임매니저 코드고요
아래 코드는 square.cs파일입니다
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class gameManager : MonoBehaviour
{
public GameObject square;
public Text timeTxt;
float alive = 0f;
public static gameManager I;
public GameObject endPanel;
void Awake()
{
I = this;
}
void Start()
{
InvokeRepeating("makeSquare", 0.0f, 0.5f);
}
// Update is called once per frame
void Update()
{
alive += Time.deltaTime;
timeTxt.text = alive.ToString("N2");
}
void makeSquare()
{
Instantiate(square);
}
public void gameOver()
{
Time.timeScale = 0f;
endPanel.SetActive(true
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class square : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
float x = Random.Range(-3.0f, 3.0f);
float y = Random.Range(3.0f, 5.0f);
transform.position = new Vector3(x, y, 0);
float size = Random.Range(0.5f, 1.5f);
transform.localScale = new Vector3(size, size, 1);
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "balloon")
{
gameManager.I.gameOver();
}
}
}
