SteamVR 2.3.2 获取手柄 并触发震动

 

先写一个控制类的脚本

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

public class ShockController : MonoBehaviour
{
    public SteamVR_Action_Vibration hapticAction;
    public SteamVR_Action_Boolean trackpadAction;

    // Start is called before the first frame update
    void Start()
    {
   
    }

    // Update is called once per frame
    void Update()
    {
        if (trackpadAction.GetLastStateDown(SteamVR_Input_Sources.RightHand))
        {
            Pulse(1, 150, 75, SteamVR_Input_Sources.RightHand);
        }

        if (trackpadAction.GetLastStateDown(SteamVR_Input_Sources.LeftHand))
        {
            Pulse(1, 150, 75, SteamVR_Input_Sources.LeftHand);
        }
    }


    private void Pulse(float duration, float frequency, float amplitude, SteamVR_Input_Sources source)
    {
        hapticAction.Execute(0, duration, frequency, amplitude, source);
        print("Pluse");
    }

}

2. 可以建个空物体

挂上你的控制脚本 Shock Controller,

再挂上插件脚本 SteamVR_Activate Action Set

在画线的地方 设置你得手柄输入(哪种情况下震动)

 

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页