2019年3月26日 星期二

Week06 葉政翰 搞懂VR程式碼

1. 寫VR Getpinch

using System.Collections; using System.Collections.Generic; using UnityEngine; using Valve.VR; // 自己寫的程式碼 public class vive : MonoBehaviour { public SteamVR_Action_Boolean triggerDown; // Update is called once per frame void Update() { if(triggerDown.GetState(SteamVR_Input_Sources.Any)) { print ("Tes"); // 如果get到手把trigger按下去,print出 triggerDown } }


寫VR Getpinch 產生出球

using System.Collections; using System.Collections.Generic; using UnityEngine; using Valve.VR; // 自己寫的程式碼 public class vive : MonoBehaviour { public SteamVR_Action_Boolean triggerDown;
public GameObject mysphere; // 獲取物件

float x=0; // 這行是我們自己寫的
// Update is called once per frame void Update() { if(triggerDown.GetStateDown(SteamVR_Input_Sources.Any)) { print ("Tes"); // 如果get到手把trigger按下去,print出 triggerDown
GameObject object = Instaniate(myspere);
} }


3D 繪圖在VR

using System.Collections; using System.Collections.Generic; using UnityEngine; using Valve.VR; // 自己寫的程式碼 public class vive : MonoBehaviour { public SteamVR_Action_Boolean triggerDown;
public GameObject mysphere; // 獲取物件
public GameObject myController; //獲取手把

float x=0; // 這行是我們自己寫的
// Update is called once per frame void Update() { if(triggerDown.GetStateDown(SteamVR_Input_Sources.Any)) { print ("Tes"); // 如果get到手把trigger按下去,print出 triggerDown
GameObject object = Instaniate(myspere);
transform.position = myController.transform.position; } }


沒有留言:

張貼留言