2019年3月5日 星期二

Week03 +1 notes


VR Cardboard DIY 



扣板機 手把震動



手把按壓數值是0~1
手把全按數值是1


程式碼

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

public class MyScript : MonoBehaviour
{
    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 Update()
    {
        if(triggerDown.GetState(SteamVR_Input_Sources.Any))
        {
            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);
        }
        if (padPos != Vector2.zero)
        {
            print(padPos);
        }
     }

 
}

沒有留言:

張貼留言