tryGrab method

bool tryGrab(
  1. ControllerState controller
)

Attempts to grab this node from a controller.

Implementation

bool tryGrab(ControllerState controller) {
  if (isGrabbed) return false;

  final dist = (node.worldPosition - controller.position).length;
  if (dist > maxGrabDistance) return false;

  isGrabbed = true;
  grabbedBy = controller.hand;
  _grabOffset = node.worldPosition - controller.position;
  _grabRotationOffset =
      controller.transform.rotation.conjugated() * node.transform.rotation;
  _prevPosition = node.transform.position.clone();
  onGrabStart?.call(node);
  return true;
}