Interhaptics SDK for Unity 1.6
Loading...
Searching...
No Matches
Interhaptics.Utils.EventHapticSource Class Reference

Haptic source that plays a haptic effect when triggered by an event. Plays the haptic effect on the specified body parts. More...

Inheritance diagram for Interhaptics.Utils.EventHapticSource:
Interhaptics.Internal.HapticSource

Public Member Functions

override void Play ()
 Plays the haptic effect on the specified body parts.
 
override void Stop ()
 Stops the haptic effect on the specified body parts.
 
override void PlayEventVibration ()
 Method to start the coroutine from outside (if necessary). Plays the haptic effect after the vibrationOffset.
 
- Public Member Functions inherited from Interhaptics.Internal.HapticSource
virtual void ApplyTargetIntensity ()
 
void ApplySourceIntensity ()
 Call this method to apply the source intensity.
 
void ApplyLooping (int loopValue)
 Call this method to apply the looping state.
 
void DebugMode (string debugMessage)
 Debug method to print messages in the console only when debugMode is enabled.
 
void AddTarget (List< HapticBodyMapping.CommandData > Target)
 Call this method to add a target to the haptic effect.
 
void RemoveTarget (List< HapticBodyMapping.CommandData > Target)
 Call this method to remove a target from the haptic effect.
 
virtual IEnumerator ControlVibration ()
 Controls the vibration perception based on the full length of the haptic material; stops any residual haptics which might come from the controller after the haptic playback length (made for platforms other than mobile)
 

Public Attributes

HapticBodyPart[] hapticBodyParts
 
- Public Attributes inherited from Interhaptics.Internal.HapticSource
HapticMaterial hapticMaterial
 
bool useStreamingAssets = false
 
string hapticEffectStreamingAssetsPath
 
float vibrationOffset
 
bool debugMode
 
bool isLooping
 
int maxLoops = 1
 
float maxLoopTime = 10f
 
double targetIntensity = 1.0
 
bool playAtStart = false
 
bool isPlaying = false
 
double hapticEffectDuration = 0
 
Coroutine playingCoroutine = null
 
double loopStartTime = 0
 

Protected Member Functions

override void Start ()
 Initialize the haptic effect settings at the start of the game.
 
- Protected Member Functions inherited from Interhaptics.Internal.HapticSource
virtual void Awake ()
 Add the haptic effect file to the when the object is created. The haptic effect file can be in the StreamingAssets folder if the useStreamingAssets property is set to true.
 
virtual void Update ()
 Update the haptic effect settings at every frame.
 

Additional Inherited Members

- Static Public Attributes inherited from Interhaptics.Internal.HapticSource
const string ERROR_MESSAGE_MONO = "Interhaptics requires IL2CPP scripting backend for Android. Please change it in Player Settings. Haptics will not play on the Mono scripting backend on the Android platform."
 
- Properties inherited from Interhaptics.Internal.HapticSource
int HapticMaterialId [get, set]
 
float SourceIntensity [get, set]
 

Detailed Description

Haptic source that plays a haptic effect when triggered by an event. Plays the haptic effect on the specified body parts.

Definition at line 19 of file EventHapticSource.cs.

Member Function Documentation

◆ Play()

override void Interhaptics.Utils.EventHapticSource.Play ( )
virtual

Plays the haptic effect on the specified body parts.

Reimplemented from Interhaptics.Internal.HapticSource.

Definition at line 34 of file EventHapticSource.cs.

35 {
36 // Check if all HapticBodyParts have TargetIntensity set to 0, and if so, do not play.
37 if (hapticBodyParts.All(hbp => hbp.TargetIntensity == 0))
38 {
39 DebugMode("All TargetIntensity values are set to 0, not playing haptic effect.");
40 return; // Exit the method without playing.
41 }
42 AddTarget(hapticBodyParts.Select(hapticBodyPart => new CommandData(Operator.Plus, hapticBodyPart.BodyPart, hapticBodyPart.Side)).ToList());
43 base.Play();
44 }
void DebugMode(string debugMessage)
Debug method to print messages in the console only when debugMode is enabled.
void AddTarget(List< HapticBodyMapping.CommandData > Target)
Call this method to add a target to the haptic effect.
Operator
Enumeration for operator signs in haptic command data.
Structure for command data in haptic systems.

References Interhaptics.Internal.HapticSource.AddTarget(), Interhaptics.Internal.HapticSource.DebugMode(), and Interhaptics.Utils.EventHapticSource.hapticBodyParts.

◆ PlayEventVibration()

override void Interhaptics.Utils.EventHapticSource.PlayEventVibration ( )
virtual

Method to start the coroutine from outside (if necessary). Plays the haptic effect after the vibrationOffset.

Reimplemented from Interhaptics.Internal.HapticSource.

Definition at line 58 of file EventHapticSource.cs.

59 {
60 AddTarget(hapticBodyParts.Select(hapticBodyPart => new CommandData(Operator.Plus, hapticBodyPart.BodyPart, hapticBodyPart.Side)).ToList());
61 base.PlayEventVibration();
62 }

References Interhaptics.Internal.HapticSource.AddTarget(), and Interhaptics.Utils.EventHapticSource.hapticBodyParts.

Referenced by Interhaptics.Samples.HapticControlGUI.StartHaptics().

◆ Start()

override void Interhaptics.Utils.EventHapticSource.Start ( )
protectedvirtual

Initialize the haptic effect settings at the start of the game.

Reimplemented from Interhaptics.Internal.HapticSource.

Definition at line 24 of file EventHapticSource.cs.

25 {
26 AddTarget(hapticBodyParts.Select(hapticBodyPart => new CommandData(Operator.Plus, hapticBodyPart.BodyPart, hapticBodyPart.Side)).ToList());
27 base.Start();
28 }

References Interhaptics.Internal.HapticSource.AddTarget(), and Interhaptics.Utils.EventHapticSource.hapticBodyParts.

◆ Stop()

override void Interhaptics.Utils.EventHapticSource.Stop ( )
virtual

Stops the haptic effect on the specified body parts.

Reimplemented from Interhaptics.Internal.HapticSource.

Definition at line 49 of file EventHapticSource.cs.

50 {
51#if !UNITY_PS5 //PS5 platform needs this commented out, otherwise residual haptics and no haptic playback until provider update - TODO: remove this when PS5 provider is updated
52 base.Stop();
53 //RemoveTarget(hapticBodyParts.Select(hapticBodyPart => new CommandData(Operator.Plus, hapticBodyPart.BodyPart, hapticBodyPart.Side)).ToList());
54#endif
55 }

Referenced by Interhaptics.Samples.HapticControlGUI.StopHaptics().

Member Data Documentation

◆ hapticBodyParts


The documentation for this class was generated from the following file: