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 castor · Oct 22, 2013 at 04:35 PM · editorinventorycombineitems

Combine items in inventory (a la LucasArts)

I guess this is more trying to figure out the best way to think about the problem.

I'm halfway through a project where the character can combine items with each other. Each combination, if possible results in a different reaction from the character and a unique result (sometimes a new object, sometimes changes on the original object etc)

If the combination is impossible the character can say the generic "Not sure how to do that" or sometimes a more specific reply about why its impossible to combine the 2 objects.

The way I do it so far is compare if the names of the objects are "acceptable" using a generic list

 combinationsList.Add("Ambien Pills, Mug with tea satchet");
     combinationsList.Add("Ambien Pills, Mug with cold water");
     combinationsList.Add("Ambien Pills, Mug with hot water");
     combinationsList.Add("Ambien Pills, Mug with sleeping pills");

If the combination is in the list then sort the result between the two objects:

 if (x.basicProperties.objName == "Ambien Pills"){
         //Mug
         if (y.basicProperties.objName == "Mug"){
             playerInteractions.SaySingleThought("Added a couple of pills to the mug.");
             audio.PlayClipAtPoint(x.customAudioClip01, x.transform.position);
             
             y.basicProperties.objName = "Mug with sleeping pills";
             y.basicProperties.lookAtDescription = "It has a couple of sleeping pills.";
         }
         //Mug with tea satchet
         else if (y.basicProperties.objName == "Mug with tea satchet"){
             playerInteractions.SaySingleThought("Added a couple of pills to the mug.");
             audio.PlayClipAtPoint(x.customAudioClip01, x.transform.position);
             
             y.basicProperties.objName = "Mug with tea satchet and sleeping pills";
             y.basicProperties.lookAtDescription = "A mug with sleeping pills and a tea satchet.";
         }

This is doing exactly what I need but I think it will get messy once I have a lot of objects.

After thinking a while this is how I think I should do it:

  • Each object adds himself to an array

  • In the editor, per object, I have the option to "add" objects" that I want the selected object to interact with (like a drop down list from the array I created).

  • Once I added a object combination to the selected object I can write the custom code that will be executed when the combination happens.

This way I could just select an object to see what are the current valid combinations and quickly add more.

Now I don't know how I go about doing the drop down list from the array in the editor. And how would I be able to write custom code in the editor that will run in game for each interaction?

Hope the question is clear, thanks in advance!

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

15 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

Related Questions

stack by quanity...? C# 2 Answers

Database error updating inventory 0 Answers

Inventory armor wielding proplem,How to convert from derived to base 1 Answer

Pickable items; Editor vs Savegame 2 Answers

Equipting a Item/Weapon 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