• 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 /
This question was closed Nov 08, 2015 at 10:38 AM by Vylax for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Vylax · Nov 07, 2015 at 02:49 PM · inventoryitems

C# Inventory items use help

Hi, in the game I made I have a short inventory system(I found it on a forum) (don't like rpg inventory) and I need help to use item, my script :

     //.......
      if (!remove)
 {
     currentItem = slot1;
     messageint = 100;
     messagetext = slot1 + " Used";
     ActivateItems(currentItem);
     slot1 = "Empty 1";
 }
 //......
 void ActivateItems(string slot)
     {
         
     }

I have différent items : Key, Meditkit and etc... I want to be help to complete the void ActivateItems. What must I put it inside ? (sorry for my bad english)

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

  • Sort: 
avatar image
1
Best Answer

Answer by NightLucididty · Nov 07, 2015 at 03:47 PM

Well it really depends on what you want the items to do, If I were you I would make an if statement checking what this "Item" is, So something like this

 void ActivateItems(string slot) {
      if(currentItem == "Key") {
         //open door (You add your own thing)
 }
      if(currentItem == "MeditKit") {
         //Heal player (You add your own thing)
 }
      if(currentItem == "Potion") {
         //Make player fly or watever (You add your own thing)
 }
      if(currentItem == "Alarm") {
         //Attract other players/enemys (You add your own thing)
 }
      }

Thats all I can say with what you have given me... Maybe with more info I could help in a better way.

Comment
Add comment · Show 1 · 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 Vylax · Nov 07, 2015 at 04:32 PM 0
Share

Thank you, that just the answer I wanted.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

33 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

Related Questions

Enum filter for Item system 1 Answer

Problem with using an item from inventory 0 Answers

Make LoadObjectsOfTypeAll load objects that have not been loaded 0 Answers

How to save bought items and show them on my inventory ? 0 Answers

int variable from dictionary? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges