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 Ouija · May 20, 2014 at 04:45 AM · inventorypointoldwander

Old School LucasArts Inventory Selection

Hey guys, this isn't a question on how to make an inventory system. I already have a simple one figured out from a previous project. I guess what I am really wondering is, Does anyone have any ideas on how to go about adding, Look At, Pick Up, Push, Pull Etc. Kinda like how the old Lucas Arts games used to work? Actually even figuring "Pick Up." is a great start for tonight.

What is bugging me about that is, You only want the "loot" to go into your inventory once the character is next to that object. Making the character walk to the destination shouldnt be overly hard to figure out, I'm thinking about taking a look at that code provided by Unity. They have one where a Bear walks wherever you click. But I'm not sure how to go about making sure he only picks it up when you click the "loot" and when he is near it. Any ideas to get my brain working would be great ;) Sorry if this was worded weirdly.

Edit: I been thinking that, if you click on say "pickup" an invisible cube attached to the character enables, which has a script applied to it to add the loot to the inventory. And if you click on "look at" another invisible box enables. It would indeed work I think, but i'm not sure that's the best method... what do you think?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by supernat · May 20, 2014 at 04:54 AM

A couple of approaches stand out to me. You could measure the distance between the player and the object in question, and only allow it to be transferred to inventory if the range is less than some threshold. If they click on it, and the range is outside of that threshold, then you move the player toward the object instead.

Another approach though I think is less viable due to more processing power required to do it, is to place a collider around the object that is larger than the object, and use that collider (set it to trigger) to detect when the player is within that zone. Then you can set some local flag on the object like "inZone" to true or false, depending if the collider trigger has entered or exited with the player. And when the player clicks on the object, it can check to see if it is inZone. I don't like this idea because it adds extra collision detection which you need to keep minimal, so use the range instead if you can.

Regarding the rest of your question. It depends on how you implement the UI system. Will the user explicitly be required to click an icon (Look At, Pick Up, Walk To)? Or do you want an automatic system such that if it is far away, it defaults to Walk To, and if you're close it defaults to Pick Up? In the former case, you just need a simple state machine to track the user's preferred method of action based on their selection. Then when they click the object, you do that thing. In the latter, you would still just use the distance to determine if the object was in range and choose the best Action based on the range. For instance, a potion could be Walked to, then picked up, and a NPC could be walked to, then talked to.

Comment
Add comment · Show 6 · 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 Ouija · May 20, 2014 at 04:56 AM 0
Share

Thanks man, Just now I was kinda thinking along the lines of your second suggestion... it seems there might be a few ways to do it. Take a look at the "edit" I added in the question, tell me what you think... it seems like a painful way to do it that way though for every object. hmmmmm

avatar image Ouija · May 20, 2014 at 05:01 AM 0
Share

Very interesting about the distance. Um yeah, I wanted the user to actually click on (look at, pick up)nothign automatically done. I love puzzle games

avatar image Ouija · May 20, 2014 at 05:03 AM 0
Share

Wait I take that back, it's late here lolol. You are correct yes. If you already have "pick up" selected I would like him to walk over to it and pick it up.

avatar image supernat · May 20, 2014 at 05:04 AM 0
Share

I'm not sure I follow exactly the Edit in the question. I mean I would be doing everything with a static script. You don't need any particular game objects to attach the inventory scripts too (though you can do that if you want).

I would just use a set of static methods and static variables in an Inventory script to store and retrieve information about the inventory. And if you wanted to keep from destroying and re-creating meshes at runtime, you could have a GameObject attached to the player called "Inventory" that you parent the lootable items to when the player picks them up. That way, the items are all stored under a gameobject somewhere in the player hierarchy, but you would just disable their renderers, and then re-enable the renderer and unparent the loot, if they wanted for instance to place the object back on the ground in front of them.

avatar image Ouija · May 20, 2014 at 05:09 AM 0
Share

haha my explaining is pretty bad I know. I think it deals with me not knowing exactly what I want to do with it. I'm gonna give your last suggestion a go just for the hell of it. I need some kinda starting point for trial and error. Thanks buddy! you got my brain turning either way :)

Show more comments
avatar image
0

Answer by Romano · May 20, 2014 at 05:32 AM

In my game I'm using what the adventure game studio used to call hotspots, so if you want to pick up an apple and you have clicked "Pick up apple" the player will walk to the apple's hotspot, which is a point on the screen that the player can pick up the apple from.

So you'd need something like:

 if (player.transform.position == appleHotspot)
 {
   // allow them to pick up the apple
 }

Of course you only want that if you've clicked "pick up apple", so you'd need something that disables that code if the user just happens to walk past it. If you want to be super fancy you could give the user the ability to change their minds. So if they click "pick up apple" but decide they don't want to pick up the apple before the character has walked over there, then clicking somehow disables that code.

Some ways of doing something like this might either be a separate script attached to the object (like the apple) that is enabled and disabled when it can and cant be picked up. Or using coroutines, which would probably be great, but would take a bit of learning if youre not familiar with them.

Comment
Add comment · 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

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

22 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

Related Questions

BurgZerg Arcade inventory system tutorials... Incomplete!! 1 Answer

Trouble working with a Custom class, JavaScript. 2 Answers

C# syntax seems fine, why wont yeild work? (Unsolved) 1 Answer

GUISkin is overlaying my button image 0 Answers

GUI.DragWindow causing Inventory Tooltip to stop showing 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