-3D小畫家 -
1. Unity、Steam VR、Vive、VS Code 設定
2.設定Trigger Down
3.按下手把出現物件
4.由手把座標位置決定物件位置
程式碼:
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;
}
}
}
沒有留言:
張貼留言