커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
마지막 부분인 풍선이 죽기직전 빨강으로 변하는것에 대한 문의입니다.
undefined주차
북마크
허*우
댓글
4
추천
0
조회수
13
조회수
13
답변 완료

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

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



balloon_die라는 animaion을 만들어놨는데 잘 적용이 된건지 모르겠어요..


balloon animation을 더블클릭했을때 make transition만 화살표 처리 해놓으면 되는건가요??


네모 박스에 부딪혀도 빨강색으로 변하며 터지지않는데요,, 영상을 아무리 돌려봐도 모르겠습니다..


마지막으로 위에서 떨어지는 네모가 원에 부딪혔을때 에러도같이출력이 됩니다.

[Animator is not playing an AnimatorController

UnityEngine.Animator:SetBool (string,bool)

gameManager:gameOver () (at Assets/Scripts/gameManager.cs:51)

squrae:OnCollisionEnter2D (UnityEngine.Collision2D) (at Assets/Scripts/squrae.cs:27)]



스파르타 즉문즉답스파르타 즉문즉답




# gameManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;




public class gameManager : MonoBehaviour
{


    public Text timeTxt;
    public GameObject square;
    float alive = 0f;
    public GameObject endPanel;
    public static gameManager I;
    public Text thisScoreTxt;
    bool isRunning = true;
    public Text maxScoreTxt;
    public Animator anim; 


    void Awake()
    {
        I = this;
    }


    // Start is called before the first frame update
    void Start()
    {
        Time.timeScale = 1f;
        InvokeRepeating("makeSquare", 0.0f, 0.5f);
    }


    // Update is called once per frame
    void Update()
    {
        if (isRunning)
        {
            alive += Time.deltaTime;
            timeTxt.text = alive.ToString("N2");
        }
    }


    void makeSquare()
    {
        Instantiate(square);
    }


    public void gameOver()
    {
        isRunning = false;
        anim.SetBool("isDie", true);
        Invoke("timeStop", 0.5f);
        Time.timeScale = 0f;
        endPanel.SetActive(true);
        thisScoreTxt.text = alive.ToString("N2");


        if(PlayerPrefs.HasKey("bestscore") == false)
        {
            PlayerPrefs.SetFloat("bestscore", alive);
        }
        else
        {
            if(alive > PlayerPrefs.GetFloat("bestscore"))
            {
                PlayerPrefs.SetFloat("bestscore", alive);
            }
        }
        float maxScore = PlayerPrefs.GetFloat("bestscore");
        maxScoreTxt.text = maxScore.ToString("N2");
    }


    public void retry()
    {
        SceneManager.LoadScene("MainScene");
    }


    void timeStop()
    {
        Time.timeScale = 0f;
    }
}



# square. cs

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


public class squrae : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        float x =Random.Range(-3f, 3f);
        float y = Random.Range(33f, 5f);
        transform.position = new Vector3(x, y, 0);


        float size = Random.Range(0.5f, 1.5f);
        transform.localScale = new Vector3(size, size, 0);
    }


    // Update is called once per frame
    void Update()
    {
        
    }
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "balloon")
        {
            gameManager.I.gameOver();
        }
    }
}


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