1using System.Collections;
2using System.Collections.Generic;
6using Valve.VR.InteractionSystem;
16 private float magnetDistance = 0.01f;
20 private ModelRenderer[] htRenderers;
33 htLeft = GameObject.Find(
"LeftHandModelMask").GetComponent<
HackedHand>();
34 htRight = GameObject.Find(
"RightHandModelMask").GetComponent<
HackedHand>();
35 htRenderers = FindObjectsOfType<ModelRenderer>();
41#if !UNITY_WEBGL && DANA
43 int layerMask = (1 << 9) + (1 << 5);
44 layerMask = ~layerMask;
46 if (
Physics.Raycast(transform.position, transform.forward + (-transform.up * 0.1f), out var hit, Mathf.Infinity, layerMask))
51 Debug.Log(hit.transform.gameObject);
54 Debug.DrawRay(transform.position, transform.TransformDirection(
Vector3.forward) * hit.distance,
Color.magenta);
56 target = hit.transform.gameObject;
63 if (lastThrowable && lastThrowable != tcd)
67 tcd.ForceHoverBegin();
71 if (!tcd.IsAttachedToHand() && tcd.pickedUpTime + 2.0f < Time.time)
73 var left =
Vector3.Distance(tcd.transform.position, htLeft.transform.position) < magnetDistance;
74 var right =
Vector3.Distance(tcd.transform.position, htRight.transform.position) < magnetDistance;
78 htLeft.
AttachObject(tcd.gameObject, GrabTypes.Grip, tcd.attachmentFlags, tcd.attachmentOffsetLeft);
82 htRight.
AttachObject(tcd.gameObject, GrabTypes.Grip, tcd.attachmentFlags, tcd.attachmentOffset);
87 else if (lastThrowable !=
null && lastThrowable.hoveringRN)
95 Debug.DrawRay(transform.position, transform.forward * 1000,
Color.red);
96 if (lastThrowable !=
null && lastThrowable.hoveringRN)
104 private void UpdateTargets(GameObject
target)
106 if (htRenderers !=
null)
107 foreach (var modelRenderer
in htRenderers)
109 modelRenderer?.GazeTargetUpdate(
target);
static GazePickupHelper instance
override void AttachObject(GameObject objectToAttach, GrabTypes grabbedWithType, AttachmentFlags flags=defaultAttachmentFlags, Transform attachmentOffset=null)