private void CheckForInteractionObject() { Collider[] overlappedColliders = Physics.OverlapSphere(snapColliderOrigin.position, snapColliderOrigin.lossyScale.x / 2f); foreach (Collider overlappedCollider in overlappedColliders) { if (overlappedCollider.CompareTag("InteractableObjects") && overlappedCollider.GetComponent <ObjectsGrab>().IsFree()) { objectBeingInteractedWith = overlappedCollider.GetComponent <ObjectsGrab>(); objectBeingInteractedWith.OnTriggerWasPressed(this); return; } } }
void Update() { if (Controller.GetHairTriggerDown()) { CheckForInteractionObject(); } if (Controller.GetHairTrigger()) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerIsBeingPressed(this); } } if (Controller.GetHairTriggerUp()) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerWasReleased(this); objectBeingInteractedWith = null; } } }
public void SwitchInteractionObjectTo(ObjectsGrab interactionObject) { objectBeingInteractedWith = interactionObject; objectBeingInteractedWith.OnTriggerWasPressed(this); }