void Start() { vp = GetComponent <VRPickup>(); if (hand && hand.attachedObject == null) { hand.AttachToHand(vp); } }
public void AttachToHand(VRPickup pickup) { if (isHolding) { Debug.LogAssertion(gameObject.name + ": Trying to attach pickup on an unempty hand"); return; } pickup.AttachToHand(this); }
public bool RequestDetachFromHand(VRPickup requster) { if (requster == null || requster != m_attachedObject) { Debug.LogError(gameObject.name + ": Error on detaching pickup from hand: wrong or null pickup"); return(false); } m_attachedObject = null; return(true); }
public bool RequestAttachToHand(VRPickup requster) { if (attachedObject != null) { Debug.LogError(gameObject.name + ": Error on attaching pickup to hand: unempty hand"); return(false); } m_attachedObject = requster; return(true); }
void OnTriggerExit(Collider other) { VRPickup pickup = other.GetComponentInParent <VRPickup>(); if (pickup) { if (!pickupsInTrigger.Contains(pickup)) { Debug.LogError(gameObject.name + ": An unlisted pickup exit the trigger: " + pickup); return; } pickupsInTrigger.Remove(pickup); } }
void OnTriggerEnter(Collider other) { VRPickup pickup = other.GetComponentInParent <VRPickup>(); if (pickup) { if (pickupsInTrigger.Contains(pickup)) { Debug.LogError(gameObject.name + ": An pickup enters the trigger twice: " + pickup); return; } pickupsInTrigger.Add(pickup); } }