1.期末製作
透過TouchPad移動位置
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
public class ViveInput : MonoBehaviour
{
public GameObject CameraRig;
public SteamVR_Action_Boolean triggerDown;
public SteamVR_Action_Vibration hapticAction;
public SteamVR_Action_Single squeezeAction;
public SteamVR_Action_Vector2 touchpadTouch;
// Start is called before the first frame update
void Start()
{
}
bool bPressed=false;
Vector2 oldPos;
// Update is called once per frame
void Update()
{
//問題 移動方向不會跟頭的方向一樣(未解決)
Vector2 padPos = touchpadTouch.GetAxis(SteamVR_Input_Sources.Any);
if(padPos != Vector2.zero){
if(bPressed==false){
oldPos = padPos;
bPressed=true;
}
}else
{
bPressed=false;
oldPos=Vector2.zero;
}
Vector2 goSpeed2 = padPos-oldPos;
Vector3 goSpeed3 = new Vector3(-goSpeed2.x, 0, -goSpeed2.y);
Quaternion headDirection = CameraRig.transform.rotation;///SteamVR CameraRig 's rotation of HMD
Vector3 realSpeed = headDirection * goSpeed3;
CameraRig.transform.position += realSpeed*3;
if(triggerDown.GetState(SteamVR_Input_Sources.RightHand))
{
hapticAction.Execute(0, 1, 150, 75, SteamVR_Input_Sources.RightHand);
print ("triggerDown");
}
if(triggerDown.GetState(SteamVR_Input_Sources.LeftHand))
{
hapticAction.Execute(0, 1, 150, 75, SteamVR_Input_Sources.LeftHand);
print ("triggerDown");
}
float triggerValue = squeezeAction.GetAxis(SteamVR_Input_Sources.Any);
//Vector2 padPos = touchpadTouch.GetAxis(SteamVR_Input_Sources.Any);
if(triggerValue > 0.0f)
{
print(triggerValue);
}
}
}
2.maya 製作
沒有留言:
張貼留言