SteamVR 2.3.2 获取手柄 并触发震动

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/chuan403082010/article/details/95368174

承接ARVR外包项目   史小川QQ: 2118590660
ARVR行业交流QQ群:750656715
公众号: ARVR行业领跑者
B站: ARVRinChina

先写一个控制类的脚本

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

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

 

展开阅读全文

没有更多推荐了,返回首页