2019年3月26日 星期二

Week06 安淇的筆記

download & import steamVR
老師有說明其實不需要全部匯入
可自行決定匯入需要的

下載visual studio code
要記得更改為vs code

按下手把產生物件
程式碼:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;

public class MyScript : MonoBehaviour
{
    public SteamVR_Action_Boolean triggerDown;
    // Start is called before the first frame update
    public GameObject mysphere; 
    public GameObject myController;
    bool state=false; 
  
    void Update()
    {
        if(triggerDown.GetState(SteamVR_Input_Sources.Any))
        {
            if(state==false)
            {
                state=true;

                print("triggerDown");

            GameObject now=Instantiate(mysphere);
            //now.transform.position = new Vector3(x,0,0); 
            //x++;
            now.transform.position=myController.transform.position;
            }
        }
        else
        {
            state=false;
        }
    }    
}

沒有留言:

張貼留言