2019年5月28日 星期二

Week15_第十三堂 期末專題報告進度

差不多場景的設計好了與模型基本都擺放好,要作將木頭放到切割台變成木材的小動畫。

Unity製作Animation的教學網頁↓

注意要到Animtor要新增新的state才不會一開始就撥放,與loop要關掉不然會一直播放。
作動畫的物件一定要在場景裡。

作了木頭切割機的動畫與瓦片塗膠的動畫。
anim.Play("Newcut1", 0, 0);
anim.Play("(動畫名稱)",(layer層),(從動畫幾秒開始撥放))
木頭碰到切割機後會播一段動畫,再生成木材。
要加上延長時間的程式碼Invoke
教學網頁↓

程式碼:

void Load()
    {
        Vector3 boxPods1 = GameObject.FindWithTag("desk").transform.position;
        Vector3 boxPod1 = new Vector3(2f, 1f, -4.5f) + boxPods1;
        Instantiate(_Pre_Cube, boxPod1, Quaternion.identity);
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == "a")
        {
            Destroy(collision.gameObject);
            //anim.Play("Newcut1");
            anim.Play("Newcut1", 0, 0);
            print("destory");
            //Vector3 boxPods1 = GameObject.FindWithTag("desk").transform.position;
            //Vector3 boxPod1 = new Vector3(2f, 1f, -4.5f) + boxPods1;
            Invoke("Load", 1.5f);
            //Instantiate(_Pre_Cube, boxPod1, Quaternion.identity);
            print("yes");
        }
    }

沒有留言:

張貼留言