커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
Animator is not playing an AnimatorController 에러 해결책을 알려주세요.
게임개발 종합반 v0
4주차
북마크
박*현
댓글
8
추천
0
조회수
17
조회수
17
답변 완료

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

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


처음 카드 두개를 눌렀을 때 같지않으면 카드 뒷면이 나와야하는데, Animator is not playing an AnimatorController 에러가 뜨면서 마지막 한장이 뒤집어지지 않네요. 그 이후에 누르면 잘 뒤집어집니다.

왜 처음에만 저럴까요?

그리고 Animator is not playing an AnimatorController 에러가 왜 뜨는지를 모르겠습니다.


card.cs에 맨 아래 CloseCardInvoke함수에서 에러가 뜹니다.

anim.SetBool("isOpen", false);  //에러가 뜨는 부분







게임 매니저와 card.cs입니다.

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


public class GameManager : MonoBehaviour
{
    public Text timeTxt;
    float time = 0.0f;


    public static GameManager Instance;


    public Card firstCard;
    public Card secondCard;


    public int cardCount = 0;


    public GameObject endTxt;


    // Start is called before the first frame update
    void Start()
    {
        Time.timeScale = 1.0f;
    }


    // Update is called once per frame
    void Update()
    {
        if (time > 30.0f)
        {
            endTxt.SetActive(true);
            Time.timeScale = 0.0f;
        }
        else
        {
            time += Time.deltaTime;
            timeTxt.text = time.ToString("N2");
        }
    }


    private void Awake()
    {
        if(Instance == null)
        {
            Instance = this;
        }
    }


    public void checkMatched()
    {
        if (firstCard.index == secondCard.index)
        {
            firstCard.DestroyCard();
            secondCard.DestroyCard();
            cardCount -= 2;


            if (cardCount == 0)
            {
                endTxt.SetActive(true);
                Time.timeScale = 0.0f;
            }
        }
        else
        {
            firstCard.CloseCard();
            secondCard.CloseCard();
        }


        firstCard = null;
        secondCard = null;
    }
}



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


public class Card : MonoBehaviour
{
    public int index = 0;


    public SpriteRenderer frontImage;


    public GameObject front;
    public GameObject back;


    public Animator anim;


    public void Setting(int idx)
    {
        index = idx;
        frontImage.sprite = Resources.Load<Sprite>($"rtan{index}");
    }


    public void OpenCard()
    {
        anim.SetBool("isOpen", true);
        front.SetActive(true);
        back.SetActive(false);


        if (GameManager.Instance.firstCard == null)
        {
            GameManager.Instance.firstCard = this;
        }
        else
        {
            GameManager.Instance.secondCard = this;
            GameManager.Instance.checkMatched();
        }
    }


    public void DestroyCard()
    {
        Invoke("DestoryCardInvoke", 1.0f);
    }


    void DestoryCardInvoke()
    {
        Destroy(gameObject);
    }


    public void CloseCard()
    {
        Invoke("CloseCardInvoke", 1.0f);
    }


    void CloseCardInvoke()
    {
        anim.SetBool("isOpen", false);  //이 부분이 에러가 뜹니다!!!
        front.SetActive(false);
        back.SetActive(true);
    }
}
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴