2019年5月21日 星期二

逸臻的筆記Week14-期末作品進度#5

-期末作品進度#5-

分開碰撞物件 ( 把一個物件套一個程式 )

球1程式碼:

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

public class bom : MonoBehaviour
{
    GameObject realBoard=null;
    public GameObject board;
    public GameObject BAT; //BAT手把
    // Start is called before the first frame update
    void Start()
    {
    
    }

    // Update is called once per frame
    float x=0;
    void Update()
    {
  

    }
    void OnTriggerEnter(Collider collision)
    {
        print("collision");
        if(realBoard==null)  realBoard = Instantiate(board); //碰撞後秀出文字板
    }
}


球2程式碼:


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

public class bom2 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
      
    }

    // Update is called once per frame
    void Update()
    {
      
    }
    void OnTriggerEnter(Collider collision)
    {
        print("collision22222");
    }  
}


沒有留言:

張貼留言