Example #1
0
 void OnTriggerExit2D(Collider2D collider)
 {
     if (collider.CompareTag("WeaponSlot"))
     {
         availableWeaponSlot?.SetPlayerInteraction(false);
         availableWeaponSlot     = null;
         isInteractingWithWeapon = false;
     }
     else if (collider.CompareTag("Interactable"))
     {
         availableInteractableObject = null;
     }
 }
Example #2
0
 public void Interaction(InputAction.CallbackContext ctx)
 {
     // gameObject.scene.IsValid check is necessary due to a bug in InputSystem: http://answers.unity.com/answers/1762099/view.html
     if (ctx.performed && gameObject.scene.IsValid())
     {
         if (availableWeaponSlot && availableWeaponSlot.AvailableForInteraction)
         {
             isInteractingWithWeapon = !isInteractingWithWeapon;
             availableWeaponSlot.SetPlayerInteraction(isInteractingWithWeapon);
         }
         else if (availableInteractableObject)
         {
             availableInteractableObject.Activate();
         }
     }
 }