Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class InteractableObject : MonoBehaviour
- {
- public bool playerInRange;
- public string ItemName;
- public string GetItemName()
- {
- return ItemName;
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Mouse0) && playerInRange && SelectionManager.Instance.onTarget && SelectionManager.Instance.selectedObject == gameObject) //add item to inventory
- {
- //is the inventory is not full
- if (InventorySystem.Instance.CheckSlotsAvailable(1))
- {
- InventorySystem.Instance.AddToInventory(ItemName);
- InventorySystem.Instance.itemsPickedup.Add(gameObject.name);
- Destroy(gameObject);
- }
- else
- {
- Debug.Log("Inventory is Full!");
- }
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.CompareTag("Player"))
- {
- playerInRange = true;
- }
- }
- private void OnTriggerExit(Collider other)
- {
- if (other.CompareTag("Player"))
- {
- playerInRange = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement