reckfellENGINE

OpenXRHapticVibration

Pulse parameters: nanoseconds, Hz and amplitude.

On this page
class OpenXRHapticVibrationReckfellSharpInherits OpenXRHapticBase

OpenXRHapticVibration describes a pulse for modifier OnHaptic/OffHaptic. Constructing the resource sends no vibration. Duration uses nanoseconds (long), Frequency Hz and Amplitude 0…1. Initially Duration=-1 requests a minimum pulse, Frequency=0 leaves frequency selection to the runtime and Amplitude=1. OpenXR units and limits.

Do not confuse Duration with TriggerHapticPulse duration, which uses seconds. This complete executed helper accepts milliseconds, rounds to a nanosecond and rejects nonfinite, out-of-range or too-small inputs before constructing a resource:

C#
using System;
using Reckfell;

public static class XrFeedback
{
    // Builds a resource for a modifier. This does not send a pulse to a device.
    // The caller owns the returned resource.
    public static OpenXRHapticVibration PulseMilliseconds(
        double milliseconds, float amplitude, float frequencyHz = 0)
    {
        double nanoseconds = Math.Round(milliseconds * 1_000_000.0);
        if (!double.IsFinite(nanoseconds) || nanoseconds < 1 || nanoseconds >= long.MaxValue)
            throw new ArgumentOutOfRangeException(nameof(milliseconds));
        if (!float.IsFinite(amplitude) || amplitude < 0 || amplitude > 1)
            throw new ArgumentOutOfRangeException(nameof(amplitude));
        if (!float.IsFinite(frequencyHz) || frequencyHz < 0)
            throw new ArgumentOutOfRangeException(nameof(frequencyHz));
        return new OpenXRHapticVibration
        {
            Duration = checked((long)nanoseconds),
            Amplitude = amplitude,
            Frequency = frequencyHz
        };
    }
}

PulseMilliseconds(20,0.5f) returns Duration=20000000, Amplitude=0.5 and Frequency=0. The caller owns the resource; assign it to the intended modifier and retain it while used. The helper creates an explicit positive request rather than the special Duration=-1.

Native setters validate no ranges. They emit Changed even for repeated values. Stored frequency or duration does not guarantee the physical result: the runtime may constrain requests to device capabilities.

Defaults, setters/getters, notifications, the exact helper, its boundaries and shared references from modifiers were checked. Vibration, extension behavior and perceived pulse strength on a device were not tested.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

OpenXRHapticVibrationConstructor
# OpenXRHapticVibration
C#
public OpenXRHapticVibration();

Creates vibration parameters with Duration=-1 ns, Frequency=0 Hz and Amplitude=1. A parameter resource: construction sends no vibration to a device.

Properties3

AmplitudeProperty
# Amplitude
C#
public float Amplitude { get; set; }

Normalized amplitude 0…1, initially 1. The setter does not enforce the Inspector range as a clamp or validate finiteness. Validate input before assignment. Changed is emitted even on repetition; property readback does not measure physical vibration strength.

DurationProperty
# Duration
C#
public long Duration { get; set; }

Duration in nanoseconds as a long. Initially -1, requesting a short pulse of the minimum supported duration. Not seconds or milliseconds. The setter performs no validation and emits Changed even on repetition. Use a positive duration for an explicit pulse; the runtime determines actual limits.

FrequencyProperty
# Frequency
C#
public float Frequency { get; set; }

Frequency in Hz, initially 0 to let the runtime choose an optimal frequency. Use a finite nonnegative value; the setter neither validates nor clamps it. Changed is emitted even on repetition. Supported device frequency may differ from the stored request.

Methods6

GetAmplitudefloat
# GetAmplitude
C#
public float GetAmplitude();

Stored normalized amplitude, initially 1; not a device measurement.

Returns float

Stored normalized amplitude, initially 1; not a device measurement.

GetDurationlong
# GetDuration
C#
public long GetDuration();

Stored duration long in nanoseconds; -1 requests the runtime minimum pulse.

Returns long

Stored duration long in nanoseconds; -1 requests the runtime minimum pulse.

GetFrequencyfloat
# GetFrequency
C#
public float GetFrequency();

Stored frequency in Hz; 0 leaves the choice to the runtime.

Returns float

Stored frequency in Hz; 0 leaves the choice to the runtime.

SetAmplitudevoid
# SetAmplitude
C#
public void SetAmplitude(float amplitude);

Normalized amplitude 0…1, initially 1. The setter does not enforce the Inspector range as a clamp or validate finiteness. Validate input before assignment. Changed is emitted even on repetition; property readback does not measure physical vibration strength.

Parameters
NameTypeDefault
amplitudefloat—
amplitude

Finite normalized amplitude in the range 0…1.

SetDurationvoid
# SetDuration
C#
public void SetDuration(long duration);

Duration in nanoseconds as a long. Initially -1, requesting a short pulse of the minimum supported duration. Not seconds or milliseconds. The setter performs no validation and emits Changed even on repetition. Use a positive duration for an explicit pulse; the runtime determines actual limits.

Parameters
NameTypeDefault
durationlong—
duration

Positive duration in nanoseconds, or -1 for the runtime minimum pulse. Not milliseconds.

SetFrequencyvoid
# SetFrequency
C#
public void SetFrequency(float frequency);

Frequency in Hz, initially 0 to let the runtime choose an optimal frequency. Use a finite nonnegative value; the setter neither validates nor clamps it. Changed is emitted even on repetition. Supported device frequency may differ from the stored request.

Parameters
NameTypeDefault
frequencyfloat—
frequency

Finite nonnegative frequency in Hz; 0 for runtime selection.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.