Open ischtz opened 3 years ago
Same issue. Seems like this argument doesnt do anything. Had to make a workaround with async/await
Looks like this is related to https://github.com/ValveSoftware/openvr/issues/1101.
Considering, issue still opened after 2 years, it will never be fixed. So we must make workaround with async/await or coroutines
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
[System.Serializable]
public class Vibrator
{
public SteamVR_Action_Vibration action;
public SteamVR_Input_Sources handType;
[Space]
public float secondFromNowOn = 0f;
public float durationSeconds = 0f;
[Range(0, 320)]
public float frequency = 0f;
[Range(0, 1)]
public float amplitude = 0f;
public async void Execute()
{
if (amplitude > 0 && frequency > 0 && durationSeconds > 0)
{
if (secondFromNowOn > 0)
await System.Threading.Tasks.Task.Delay((int)(secondFromNowOn * 1000));
action.Execute(
secondFromNowOn,
durationSeconds,
frequency,
amplitude * SettingsManager.Instance.data.vibrationPower,
handType
);
}
}
}
Hi all,
I am trying to generate controller haptics at predefined time offsets using the secondsFromNow argument of SteamVR_Action_Vibration.Execute(). However, haptics are always triggered immediately regardless of the value passed for this argument (and all code examples I could find online use 0f for this value anyway). The remaining arguments work as expected.
Am I doing something wrong, is this not the intended use of this parameter? I'd appreciate any pointers. Thanks!
Minimal example:
Expected result: Haptics triggers ~latency seconds after the sound plays.
Actual result: Haptics and sound always occur together regardless of latency, tested values in range 0.01f - 10f.
Tested versions: