10using System.Collections;
39 [Tooltip(
"The interval in seconds at which to check this detector's conditions.")]
47 [Tooltip(
"The hand model to watch. Set automatically if detector is on a hand.")]
65 [Header(
"Direction Settings")]
66 [Tooltip(
"How to treat the target direction.")]
74 [Tooltip(
"The target direction.")]
81 [Tooltip(
"A target object(optional). Use PointingType.AtTarget")]
90 [Tooltip(
"The angle in degrees from the target direction at which to turn on.")]
99 [Tooltip(
"The angle in degrees from the target direction at which to turn off.")]
107 [Tooltip(
"Draw this detector's Gizmos, if any. (Gizmos must be on in Unity edtor, too.)")]
110 private IEnumerator watcherCoroutine;
112 private void OnValidate(){
118 private void Awake () {
119 watcherCoroutine = palmWatcher();
122 private void OnEnable () {
123 StartCoroutine(watcherCoroutine);
126 private void OnDisable () {
127 StopCoroutine(watcherCoroutine);
131 private IEnumerator palmWatcher() {
139 float angleTo =
Vector3.Angle(normal, selectedDirection(hand.PalmPosition.ToVector3()));
147 yield
return new WaitForSeconds(
Period);
151 private Vector3 selectedDirection (Vector3 tipPosition) {
154 Quaternion cameraRot = Camera.main.transform.rotation;
155 float cameraYaw = cameraRot.eulerAngles.y;
172 private void OnDrawGizmos(){
181 Utils.DrawCone(hand.PalmPosition.ToVector3(), hand.PalmNormal.ToVector3(),
OnAngle, hand.PalmWidth, centerColor, 8);
182 Utils.DrawCone(hand.PalmPosition.ToVector3(), hand.PalmNormal.ToVector3(),
OffAngle, hand.PalmWidth,
LimitColor, 8);
184 Gizmos.DrawRay(hand.PalmPosition.ToVector3(), selectedDirection(hand.PalmPosition.ToVector3()));
Vector PalmNormal
The normal vector to the palm. If your hand is flat, this vector will point downward,...
virtual void Deactivate()
abstract Hand GetLeapHand()
Vector3 PointingDirection
PointingType PointingType