
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
3-5 강좌까지 따라하던 중 고양이가 게임오버 후에도 움직이는 버그를 발견했습니다.
게임오버시 캐릭터, 푸드는 정상적으로 멈춥니다.
리트라이 버튼도 정상적으로 표시됩니다.
unity editer version: 6000.0.32f1 에서 Universal2D로 프로젝트를 만들었습니다.

using UnityEngine;
public class Cat : MonoBehaviour
{
public GameObject fullCat;
public GameObject hungryCat;
public RectTransform front;
float full = 5.0f;
float energy;
void Start()
{
float x = Random.Range(-9.0f, 9.0f);
float y = 30f;
transform.position = new Vector2(x, 30f);
}
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;
}
Destroy(gameObject, 3f);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("Food"))
{
energy += 1.0f;
front.localScale = new Vector3(energy / full, 1.0f, 1.0f);
Destroy(collision.gameObject);
if(energy == 5.0f)
{
hungryCat.SetActive(false);
fullCat.SetActive(true);
}
}
}
}
추가로 첨부파일 zip파일 안올라가네요;;
