커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
InvokeRepeating 이 동작하지 않아요
undefined주차
북마크
김*우
댓글
6
추천
0
조회수
12
조회수
12
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


어느 순간부터 gameManager.cs 의 invokeRepeating 이 동작하지 않습니다. 원인 불명!!

기억으로는 gameOver 적용 하면서 발생한 것 같은데 아직 해결이 안되고 있습니다.



스파르타 즉문즉답




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 replayBtn;

  public Text levelText;

  public GameObject fishshop;

  public GameObject levelFront;


  public static gameManager I;


  int level = 0;

  int cat = 0;


  private void Awake()

  {

    I = this;

  }


  // Start is called before the first frame update

  void Start()

  {

    Time.timeScale = 1.0f;

    InvokeRepeating("makeFood", 0.0f, 0.1f);

    InvokeRepeating("makeCat", 0.0f, 1.0f);

  }


  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 < 6) Instantiate(normalCat);


      Instantiate(fatCat);

    }

  }


  public void gameOver()

  {


  }

  // Update is called once per frame

  void Update()

  {

    if (normalCat.transform.position.y == fishshop.transform.position.y)

    {

      replayBtn.SetActive(true);

      Time.timeScale = 0f;

    }


  }


  public void addCat()

  {

    cat += 1;

    level = cat / 5;

  }

}



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