6using System.Collections;
7using System.Collections.Generic;
13 [AddComponentMenu(
"Interhaptics/SpatialHapticSource")]
14 [RequireComponent(typeof(Rigidbody))]
40 base.PlayEventVibration();
49 DebugMode(
string.Format(
"Started playing haptics on Spatial HS! + {0}",Time.time));
56 [System.Diagnostics.Conditional(
"UNITY_EDITOR")]
59 SphereCollider sphere = GetComponent<SphereCollider>();
60 BoxCollider box = GetComponent<BoxCollider>();
62 if (sphere ==
null && box ==
null)
64 if (UnityEditor.EditorUtility.DisplayDialog(
"Choose a Component",
"You are missing one of the required componets. Please choose one to add",
"SphereCollider",
"BoxCollider"))
66 gameObject.AddComponent<SphereCollider>().isTrigger =
true;
70 gameObject.AddComponent<BoxCollider>().isTrigger =
true;
73 gameObject.GetComponent<Rigidbody>().useGravity =
false;
82 AddTarget(hapticBodyPart.ToCommandData());
83 hapticBodyPart.UpdateTargetIntensity(hapticBodyPart.TargetIntensity);
99 ActivateHaptics(other.gameObject);
107 ActivateHaptics(other.gameObject);
111 private void ActivateHaptics(GameObject other)
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.
double hapticEffectDuration
void RemoveTarget(GameObject target)
override void PlayEventVibration()
Method to start the coroutine from outside (if necessary). Plays the haptic effect after the vibratio...
virtual void OnCollisionExit(Collision other)
virtual void OnTriggerExit(Collider other)
override IEnumerator ControlVibration()
Controls the vibration perception based on the full length of the haptic material; stops any residual...
virtual void OnCollisionEnter(Collision other)
override void Start()
Initialize the haptic effect settings at the start of the game.
virtual void OnTriggerEnter(Collider other)
void AddTarget(GameObject target)