using UnityEngine;
namespace Passer.Humanoid {
/// Have a humaonid grab objects from a distance
/// The Humanoid Telegrabber enables humanoids to grab objects
/// which are normally out of reach for the hands.
/// This Interaction Pointer should be used on a child of a HandTarget.
[HelpURLAttribute("https://passervr.com/documentation/humanoid-control/tools/telegrabber/")]
public class Telegrabber : InteractionPointer {
protected override void Awake() {
clickEvent.SetMethod(EventHandler.Type.OnStart, GrabObject);
base.Awake();
}
/// Grab the object currently in focus of the InteractionPointer
/// If current objectInFocus is a Rigidbody, this function will have the Humanoid hand
/// try to grab the object.
public void GrabObject() {
if (objectInFocus == null)
return;
HandTarget handTarget = transform.GetComponentInParent();
if (handTarget == null)
return;
Rigidbody rigidbodyInFocus = objectInFocus.GetComponentInParent();
if (rigidbodyInFocus != null)
handTarget.GrabOrLetGo(rigidbodyInFocus.gameObject, false);
}
}
}