커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
level이 2 이상 안올라가요.
undefined주차
북마크
윤*희
댓글
3
추천
0
조회수
16
조회수
16
답변 완료

게임화면에는 3이고, 4이고 잘 올라가는데

뚱보고양이가 안나와서 디버그 로그로 확인해봤더니, 레벨이 2 이상은 올라가지 않는 것 같아요. 내부에서;;

위에 leveltext표시는 잘 올라가는데 뭔가 연결이 안된걸까요..?



스파르타 즉문즉답


gameManager.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class gameManager : MonoBehaviour
{
    public GameObject food;
    public GameObject dog;
    public GameObject normalCat;
    public GameObject fatCat;
    public GameObject pirateCat;
    public static gameManager I;
    public GameObject retryBtn;
    public Text levelText;
    public GameObject levelFront;


public void gameOver()
{
    retryBtn.SetActive(true);
    Time.timeScale = 0.0f;
}
void Awake()
{
    I = this;
}
    void Start()
    {
        Time.timeScale = 1.0f;
        InvokeRepeating("makeFood", 0.0f, 0.2f);
        InvokeRepeating("makeCat", 0.0f, 1.0f);
    }


    void makeFood()
        {
            float x = dog.transform.position.x; // dog의 위치를 기준으로 만들어주는 것
            float y = dog.transform.position.y + 2.0f;
            Instantiate(food, new Vector3(x,y,2), Quaternion.identity); //quaternion은 회전을 표현할 수 있는 데이터 타입
        }
    
    void makeCat()
{
    Instantiate(normalCat);
    
    if (level == 1)
    {
        Debug.Log("level1");
        float p = Random.Range(0, 10);
        if (p < 2) Instantiate(normalCat);
    }
    else if (level >= 2)
    {
        Debug.Log("level2");
        float p = Random.Range(0, 10);
        if (p < 5) Instantiate(normalCat);
    } 
    else if (level >= 3)
    {
        Debug.Log("level3");
        Instantiate(fatCat);
        float p = Random.Range(0, 10);
        if (p < 5) Instantiate(fatCat);
    }
    else if (level >= 4)
    {
        Debug.Log("level4");
        Instantiate(pirateCat);
        float p = Random.Range(0, 10);
        if (p < 5) Instantiate(fatCat);
    }
}
    // Update is called once per frame
    void Update()
    {
        
    }


    int level = 0;
    int cat = 0;



    public void addCat()
{
    cat += 1;
    level = cat / 5;


    levelText.text = level.ToString();
    levelFront.transform.localScale = new Vector3((cat - level * 5) / 5.0f, 1.0f, 1.0f);


}
    
}


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