Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by HuskyPanda213 · Apr 09, 2013 at 08:29 PM · fpsinventory

How to make things in my inventory able to drop and use?

Hello, in my game I want my inventory to have food and stuff that you can drop and its out of the inventory. Also i want it that you can eat food and drink liquid. I tried once but it didn't work, heres my code:(Also slot1Item-slot8Item are strings and so is weapon 2 and 1, and this is not the full script)

 public void InventoryGUI(){
         if(isInventoryUp){
             inventoryRect = GUI.Window(0, inventoryRect, InventoryWindow, "Gear");
         }
     }
     void InventoryWindow(int windowID) {
     
     if(GUI.Button(new Rect(10,30,200,60),"Weapon 1: " + Weapon1)){
         GearWeaponDesc = Weapon1Desc;
     }
         
     if(GUI.Button(new Rect(10,100,200,60),"Weapon 2: " + Weapon2)){
         GearWeaponDesc = Weapon2Desc;
     }
     if(GUI.Button(new Rect(220,30,60,60),"" + slot1Item)){
         SelectedItem = slot1Item;
         SelectedItemSlot = "1";
         DisplayEatDrop = true;
     }
     if(GUI.Button(new Rect(290,30,60,60),"" + slot2Item)){
         SelectedItem = slot2Item;
         SelectedItemSlot = "2";
         DisplayEatDrop = true;
     }
     if(GUI.Button(new Rect(360,30,60,60),"" + slot3Item)){
         SelectedItem = slot3Item;
         SelectedItemSlot = "3";
         DisplayEatDrop = true;
     }
     if(GUI.Button(new Rect(430,30,60,60),"" + slot4Item)){
         SelectedItem = slot4Item;
         SelectedItemSlot = "4";
         DisplayEatDrop = true;
     }
     if(GUI.Button(new Rect(220,100,60,60),"" + slot5Item)){
         SelectedItem = slot5Item;
         SelectedItemSlot = "5";
         DisplayEatDrop = true;
     }
     if(GUI.Button(new Rect(290,100,60,60),"" + slot6Item)){
         SelectedItem = slot6Item;
         SelectedItemSlot = "6";
         DisplayEatDrop = true;
     }
     if(GUI.Button(new Rect(360,100,60,60),"" + slot7Item)){
         SelectedItem = slot7Item;
         SelectedItemSlot = "7";
         DisplayEatDrop = true;
     }
     if(GUI.Button(new Rect(430,100,60,60),"" + slot8Item)){
         SelectedItem = slot8Item;
         SelectedItemSlot = "8";
         DisplayEatDrop = true;
     }
     GUI.Box(new Rect(220,170,120,120),"Binoculars");
     GUI.Box(new Rect(370,170,120,120),"Head Gear");
         
     GUI.Label(new Rect(10,170,200,100),GearWeaponDesc);
         
     
     if(DisplayEatDrop){
         if(SelectedItem != ""){
         if(GUI.Button(new Rect(220,300,270,30),"Use")){}
         if(GUI.Button(new Rect(220,340,270,30),"Drop")){
             SelectedItem = "";
             PlayerPrefs.SetString(SelectedItemSlot,SelectedItem);
         }
         }
     }
     
     GUI.DragWindow();
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by iwaldrop · Apr 10, 2013 at 02:06 AM

You haven't really asked much of a question aside from how do you drop and use things from an inventory.

You should have a List of inventory items (a List, not an array). When you want to drop an item, simply remove it from the List and spawn it's Prefab by your player to drop it on the ground. In order to consume it, you remove it from your array and apply it's effects to your player. Awesomely easy!

Comment
Add comment · Show 2 · Share
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
avatar image HuskyPanda213 · Apr 10, 2013 at 04:42 PM 0
Share

I would like it with strings to save it easier here is a better explanation the drop button does not drop and item like it should. I could easily add consume but i need the drop in order to work for the making of consume.

avatar image iwaldrop · Apr 11, 2013 at 05:07 AM 0
Share

I don't see your code for dropping anything, and if you haven't implemented it yet I gave you a workable description of both operations in my answer. Post some code with a specific question and we'll work it out.

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

11 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

Related Questions

FPS picking up items 2 Answers

c# Weapon Pickup Script 1 Answer

FPS Weapon inventory script help 0 Answers

ufps package freezes when adding inventory system 0 Answers

Fairly Simple FPS Inventory HELP? 1 Answer


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