Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by cgmuno01 · Dec 01, 2021 at 02:09 PM · inventory system

How do I make a simple Inventory?

Hello, I am very new to unity. I have tried looking at a million videos on this topic. However, the code either goes over my head, or they seem to rush through the code, and implement features that I would not need on this inventory. I am just looking to make a simple inventory that works with a controller. I just want the inventory to hold the items when picked up, and when selected by pressing X on the PS4 controller to either be equipped or used by the player. I have gotten the UI to come up by using the options button on a PS4 controller. I have also made a simple script that I have attached to a game object which displays a pick up message, and destroys the object upon hitting X. here are the scripts for the PickUp, and inventory that I have. any help is much appreciated.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 public class PickUp : MonoBehaviour
 {
 
 public GameObject enterText;
 

 public GameObject itemIcon;

 bool pickedUp = false;

 


 // Start is called before the first frame update
 void Start()
 {
     enterText.SetActive(false);
     
     if(pickedUp == false)
     {
         itemIcon.SetActive(false);
     }

    

 }

 // Update is called once per frame
 void Update()
 {
     
 }

 private void OnTriggerStay(Collider player)
 {
     if (player.gameObject.tag == "Player")
     {
         enterText.SetActive(true);
         if (Input.GetButtonDown("Pickup") &&! pickedUp)
         {
            
             pickedUp = true;
             Destroy(gameObject);
             enterText.SetActive(false);
             itemIcon.SetActive(true);

         }
                   

     }
 }
 private void OnTriggerExit(Collider player)
 {
     if (player.gameObject.tag == "Player")
     {
         enterText.SetActive(false);
        
     }
 }
   
  

}

here is the inventory. I have also set up to pause the game when the inventory is displayed on the UI.

  using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     
     
     public class Inventory : MonoBehaviour
 
 {
     public GameObject invTab;
     public static bool GameIsPaused = false;
 public GameObject pauseMenuUI;



 // Start is called before the first frame update
 void Start()
 {
     invTab.SetActive(false);
     
 }

 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("invTab"))
     {
        
         if (GameIsPaused)
         {
             Resume();
         }
         else
         {
             Pause();
         }

        
     }
   
 }
 void Resume()
 {
     invTab.SetActive(false);
     Time.timeScale = 1f;
     GameIsPaused = false;
 }
 void Pause()
 {
     invTab.SetActive(true);
     Time.timeScale = 0f;
     GameIsPaused = true;
 }
 public void LoadMenu()
 {
     Debug.Log("Loading menu..");
 }
 public void QuitGame()
 {
     Debug.Log("Quitting Game....");
 }
 

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

171 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Inventory system: Find an empty slot with Array 1 Answer

Inventory system that stores original items rather than representative icons? 1 Answer

Stuck in a while loop inside my inventory 2 Answers

Adding a singleton script to 2 objects makes one of them dissapear. 0 Answers

IPointerExitHandler while holding click 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges