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 Olle · Nov 09, 2011 at 11:55 AM · c#3dinventory

3D inventory problem

Hey guys!

I'm still fairly new to Unity so please if you answer a question dumb yourself down ^^ thanks! :D

Anyways, I'm making a script for picking up items, then pulling them out in an 3D inventory and rotating the looked upon object.

Something like the old Alone in the Dark games and such - the idea is to have the item you are looking at in the middle of the screen and all other items you posses rotating by themselves in the bottom, then you scroll through the list and the selected item will pop up in the middle instead.. This is what I got so far:

Picking up an item:

     if(Input.GetKeyDown("e")){
     
 
 inventory[0] = hit.collider.gameObject.tag;
 
 Destroy(hit.collider.gameObject);
 
                 }

Then to call the inventory I would clone objects infront of the player which has the tags that is in the inventory. And that works.. sorta, needs some tweaking, anyways! When the items pop up I turn off the mouselook and character motor scripts so the player stands still

I can rotate an item aswell, BUT then I want to close the inventory again, turning on stuff again and removing the items from the screen. Now I cant destroy just a clone, as that isnt an object per se, and as I am not looking at all the items with a raycast, say the one looked upon, I cannot remove it :O Please help me!

I was thinking about changing to another scene when opening the inventory, but then I would have to save and load constantly, which is stupid :P ...

Any advice please?

Here is the code when the inventory pops up:

 if(Input.GetKeyDown("r") && inventoryOpen == false ){
         inventoryOpen = true;
         GameObject clone;
         clone = Instantiate(Item, transform.position + transform.forward * 0.8f + transform.up, Quaternion.identity) as GameObject;
     }

 case "inventoryItem":
             MouseLook mouseL = (MouseLook)gameObject.GetComponent(typeof(MouseLook));
             mouseL.enabled = false;
             
             CharacterMotor motor = (CharacterMotor)gameObject.GetComponent(typeof(CharacterMotor));
             motor.canControl = false;
                             
             if(Input.GetButton("Fire1")){
                 hit.transform.Rotate(((Input.mousePosition.x - (Screen.width/2)) * Time.deltaTime), ((Input.mousePosition.y - (Screen.height/2))* Time.deltaTime), 0);
             
             }
         break;

and the code when Im trying to close the inventory

 if(inventoryOpen == true){
         if(Input.GetKeyDown("r")){
             inventoryOpen = false;
             MouseLook mouseL = (MouseLook)GetComponent(typeof(MouseLook));
             mouseL.enabled = true;
             CharacterMotor motor = (CharacterMotor)GetComponent(typeof(CharacterMotor));
             motor.canControl = true;
             Destroy(Interaction.hit.collider.gameObject);
         }
     }
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

2 People are following this question.

avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Object reference not set to an instance of an object 1 Answer

[C#]For-loop in For-loop crashes Unity. 1 Answer

How to smooth out movement in a 3D space? 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