
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
레벨디자인 구성 후 고양이들이 화면에 등장하지 않고, 다음과 같은 경고창이 뜹니다.

cat cs>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cat : MonoBehaviour
{
float full = 5f;
float energy = 0f;
bool isfull = false;
public int type;
// Start is called before the first frame update
void Start()
{
float x = Random.Range(-8.5f, 8.5f);
float y = 30f; //y좌표 30에서 내려오기
transform.position = new Vector3(x, y, 0);
if (type == 1)
{
full = 10.0f;
}
}
// Update is called once per frame
void Update()
{
if (energy < full)
{
if (type == 0)
{
transform.position += new Vector3(0.0f, -0.5f, 0.0f); // 기존 위치에서 더해준다. -0.5의 속도로 내려온다
}
else if (type == 1)
{
transform.position += new Vector3(0.0f, -0.03f, 0.0f);
}
if (transform.position.y<-16.0f)
{
GameManager.I.GameOver();
}
}
else
{
if(transform.position.x > 0)
{
transform.position += new Vector3(0.05f, 0, 0); //속도??
}
else
{
transform.position += new Vector3(-0.05f, 0, 0);
}
Destroy(gameObject,3.0f);
}
}
void OnTriggerEnter2D(Collider2D coll)
{
if (coll.gameObject.tag == "food")
{
if (energy < full)
{
energy += 1f;
Destroy(coll.gameObject); // 맞은 당사자를 없애줘!
gameObject.transform.Find("hungry/Canvas/front").transform.localScale = new Vector3(energy / full, 1f, 0f);
}
else
{
if (isfull == false)
{
GameManager.I.addCat();
gameObject.transform.Find("hungry").gameObject.SetActive(false);
gameObject.transform.Find("full").gameObject.SetActive(true);
isfull = true;
}
}
}
}
}
gamemanager cs>>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public GameObject dog;
public GameObject food;
public GameObject normalCat;
public GameObject fatCat;
public GameObject retrybutton;
public Text leveltext;
public GameObject levelfront;
public static GameManager I;
int level = 0;
int cat = 0;
void Awake()
{
I = this;
}
// Start is called before the first frame update
void Start()
{
InvokeRepeating("MakeFood", 0.0f, 0.1f);
InvokeRepeating("MakeCat", 0.0f, 1f);
}
// Update is called once per frame
void Update()
{
}
void MakeFood()
{
float x = dog.transform.position.x;
float y = dog.transform.position.y + 2.0f;
Instantiate(food, new Vector3(x, y, 0), Quaternion.identity);
}
void makeCat()
{
Instantiate(normalCat);
if (level == 1)
{
float p = Random.Range(0, 10);
if (p < 2) Instantiate(normalCat);
}
else if (level == 2)
{
float p = Random.Range(0, 10);
if (p < 5) Instantiate(normalCat);
}
else if (level >= 3)
{
float p = Random.Range(0, 10);
if (p < 5) Instantiate(normalCat);
Instantiate(fatCat);
}
}
public void GameOver()
{
Time.timeScale = 0f;
retrybutton.SetActive(true);
}
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);
}
}

