커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
종류함수 넣었는데 뭔가 좀 이상하네용..
undefined주차
북마크
임*윤
댓글
13
추천
0
조회수
11
조회수
11
답변 완료

판넬 넣고 종료함수 다 넣었는데용

플레이 눌렀는데 시간 가긴 가는데

풍선이랑 네모랑 부딪혔는데도 게임 종료가 안되고 있습니다.

그리고 네모들이 너무 많이 떨어지는데 좀 천천히 내려올 수 있게 할 수 있나요?ㅜ





첫번째 코드는 게임매니저 코드고요

아래 코드는 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();
        }
    }
}




취소
 공유
취소
댓글 0
댓글 알림
나의얼굴