Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class itemScript : MonoBehaviour {
- public GameObject inventorySlot;
- public GameObject player;
- public laikaController controller;
- [SerializeField] private Text interactingText;
- public bool thereIsAnItem = false;
- public bool isActive = false;
- void Update() {
- Vector3 distance = transform.position - player.transform.position;
- if (thereIsAnItem) {
- inventorySlot.SetActive(true);
- }
- if (controller.canInteract == false) {
- interactingText.text = ("");
- }
- if (controller.canInteract == true) {
- if (isActive == false) {
- interactingText.text = ("Press E to pick up this item.");
- if (Input.GetKeyDown(KeyCode.E)) {
- inventorySlot.SetActive(true);
- thereIsAnItem = true;
- controller.canInteract = false;
- interactingText.text = ("");
- isActive = true;
- }
- } else if (isActive == true) {
- interactingText.text = ("You already own this item.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement