๐Ÿ”ฆGrabbable Highlighter

Hand Grabbable Highlighter

The HandGrabbableHighlighter class manages the highlighting of grabbable objects within reach of a hand in Unity. It periodically updates the highlighted object based on the hand's position and orientation.

Public Variables

  • Palm Forward Right Direction : When choosing between multiple targets to highlight, the hand will favor objects in the palm's local forward direction (0) or the palm's local right direction (1), or a blend between the two (recommended 0.5-0.75).

Public Methods

GetHighlightHit

csharpCopy codepublic RaycastHit GetHighlightHit()

Returns the closest raycast hit from the hand's highlighting system. If no highlight is present, returns a blank raycasthit.

Returns:

  • RaycastHit: The closest raycast hit.

HandClosestHit

csharpCopy codepublic virtual Vector3 HandClosestHit(out RaycastHit closestHit, out IGrabbableEvents grabbable, float dist, int layerMask, Grabbable target = null)

Finds the closest raycast hit from a cone of rays and returns the average direction of all hits.

Parameters:

  • closestHit: Outputs the closest raycast hit.

  • grabbable: Outputs the closest grabbable object.

  • dist: The distance to check for hits.

  • layerMask: The layer mask to use for raycasting.

  • target: An optional target grabbable object to check for.

Returns:

  • Vector3: The average direction of all hits.

Last updated