
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
전에도 올렸지만
어디서 놓친지 모르겠는데 레벨이랑 고양이 체력이랑 풀인 상태에서 시작해서 치면 점점 체력이 0에서부터 오르기 시작합니다
레벨도 그래요

작성한 코드 및 에러 메세지
CAT.cs 입니다
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cat : MonoBehaviour
{
public GameObject hungryCat;
public GameObject fullCat;
public RectTransform front;
float full = 5.0f;
float energy = 0.0f;
bool isFull = false;
// Start is called before the first frame update
void Start()
{
float x = Random.Range(-9.0f, 9.0f);
float y = 30.0f;
transform.position = new Vector2(x, y);
}
// Update is called once per frame
void Update()
{
if (energy < full)
{
transform.position += Vector3.down * 0.05f;
if(transform.position.y < -16.0f)
{
GameManager.Instance.GameOver();
}
}
else
{
if(transform.position.x > 0)
{
transform.position += Vector3.right * 0.05f;
}
else
{
transform.position += Vector3.left * 0.05f;
}
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.CompareTag("Food"))
{
if (energy < full)
{
energy += 1.0f;
front.localScale = new Vector3(energy / full, 1.0f, 1.0f);
Destroy(collision.gameObject);
if(energy == 5.0f)
{
if (!isFull)
{
isFull = true;
hungryCat.SetActive(false);
fullCat.SetActive(true);
Destroy(gameObject, 3.0f);
GameManager.Instance.AddScore();
}
}
}
}
}
}
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
