Interhaptics SDK for Unity 1.6
Loading...
Searching...
No Matches
Interhaptics.SpatialHapticSource Class Reference
Inheritance diagram for Interhaptics.SpatialHapticSource:
Interhaptics.Internal.HapticSource Interhaptics.Samples.XRControllerHapticSource

Public Types

enum  PlayMethod { Undefined , OnCollision , OnTrigger }
 

Public Member Functions

override void PlayEventVibration ()
 Method to start the coroutine from outside (if necessary). Plays the haptic effect after the vibrationOffset.
 
override 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.
 
void AddTarget (GameObject target)
 
void RemoveTarget (GameObject target)
 
- 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.
 
virtual void Play ()
 Call this method to play the haptic effect.
 
virtual void Stop ()
 Call this method to stop the haptic effect.
 
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.
 

Public Attributes

PlayMethod playMethod
 
- 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.
 
virtual void OnCollisionEnter (Collision other)
 
virtual void OnTriggerEnter (Collider other)
 
virtual void OnTriggerExit (Collider other)
 
virtual void OnCollisionExit (Collision other)
 
- 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

Definition at line 15 of file SpatialHapticSource.cs.

Member Enumeration Documentation

◆ PlayMethod

Member Function Documentation

◆ AddTarget()

void Interhaptics.SpatialHapticSource.AddTarget ( GameObject target)

Definition at line 77 of file SpatialHapticSource.cs.

78 {
79 if (target.TryGetComponent(out HapticBodyPart hapticBodyPart))
80 {
81 hapticBodyPart.HapticMaterialId = this.HapticMaterialId;
82 AddTarget(hapticBodyPart.ToCommandData());
83 hapticBodyPart.UpdateTargetIntensity(hapticBodyPart.TargetIntensity); // Update the target intensity when adding the target
84 }
85 }

References Interhaptics.SpatialHapticSource.AddTarget(), and Interhaptics.Internal.HapticSource.HapticMaterialId.

Referenced by Interhaptics.SpatialHapticSource.AddTarget().

◆ ControlVibration()

override IEnumerator Interhaptics.SpatialHapticSource.ControlVibration ( )
virtual

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.

Returns

Reimplemented from Interhaptics.Internal.HapticSource.

Definition at line 47 of file SpatialHapticSource.cs.

48 {
49 DebugMode(string.Format("Started playing haptics on Spatial HS! + {0}",Time.time));
50 Play();
51 yield return new WaitForSeconds((float)hapticEffectDuration);
52 DebugMode(string.Format("Finished playing haptics at timestamp on SpatialHS : + {0} at {1}", hapticEffectDuration, Time.time));
53 }
virtual void Play()
Call this method to play the haptic effect.
void DebugMode(string debugMessage)
Debug method to print messages in the console only when debugMode is enabled.

References Interhaptics.Internal.HapticSource.DebugMode(), Interhaptics.Internal.HapticSource.hapticEffectDuration, and Interhaptics.Internal.HapticSource.Play().

◆ OnCollisionEnter()

virtual void Interhaptics.SpatialHapticSource.OnCollisionEnter ( Collision other)
protectedvirtual

Reimplemented in Interhaptics.Samples.XRControllerHapticSource.

Definition at line 95 of file SpatialHapticSource.cs.

96 {
97 if ((playMethod == PlayMethod.OnCollision)&&(other.gameObject.GetComponent<HapticBodyPart>() != null))
98 {
99 ActivateHaptics(other.gameObject);
100 }
101 }

References Interhaptics.SpatialHapticSource.playMethod.

◆ OnCollisionExit()

virtual void Interhaptics.SpatialHapticSource.OnCollisionExit ( Collision other)
protectedvirtual

Reimplemented in Interhaptics.Samples.XRControllerHapticSource.

Definition at line 129 of file SpatialHapticSource.cs.

130 {
131 RemoveTarget(other.gameObject);
132 }
void RemoveTarget(GameObject target)

References Interhaptics.SpatialHapticSource.RemoveTarget().

◆ OnTriggerEnter()

virtual void Interhaptics.SpatialHapticSource.OnTriggerEnter ( Collider other)
protectedvirtual

Reimplemented in Interhaptics.Samples.XRControllerHapticSource.

Definition at line 103 of file SpatialHapticSource.cs.

104 {
105 if ((playMethod == PlayMethod.OnTrigger) && (other.gameObject.GetComponent<HapticBodyPart>()!=null))
106 {
107 ActivateHaptics(other.gameObject);
108 }
109 }

References Interhaptics.SpatialHapticSource.playMethod.

◆ OnTriggerExit()

virtual void Interhaptics.SpatialHapticSource.OnTriggerExit ( Collider other)
protectedvirtual

Reimplemented in Interhaptics.Samples.XRControllerHapticSource.

Definition at line 124 of file SpatialHapticSource.cs.

125 {
126 RemoveTarget(other.gameObject);
127 }

References Interhaptics.SpatialHapticSource.RemoveTarget().

◆ PlayEventVibration()

override void Interhaptics.SpatialHapticSource.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 38 of file SpatialHapticSource.cs.

39 {
40 base.PlayEventVibration();
41 }

◆ RemoveTarget()

◆ Start()

override void Interhaptics.SpatialHapticSource.Start ( )
protectedvirtual

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

Reimplemented from Interhaptics.Internal.HapticSource.

Reimplemented in Interhaptics.Samples.XRControllerHapticSource.

Definition at line 30 of file SpatialHapticSource.cs.

31 {
32 isLooping = false;
33 playAtStart = false;
34 base.Start();
35 }

References Interhaptics.Internal.HapticSource.isLooping, and Interhaptics.Internal.HapticSource.playAtStart.

Member Data Documentation

◆ playMethod

PlayMethod Interhaptics.SpatialHapticSource.playMethod

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