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 Jaqal · Oct 20, 2014 at 12:14 AM · transform

How to offset transform of each item placed.

This is a section of my code I am using for a 3d inventory system I created. I am stuck on a problem right now about how to offset the transform of each stick placed after the first one. Assume that the first stick is already placed and I would like the next for in this section to be placed next to it by a some variable. This problem is probably easier than I am making but any help is greatly appreciated.

                 if(iStickCount > 1 && iStickCount % 5 != 0)
                 {
                     if(itemPlacedInStack == false)
                     {
                         foreach (Transform child in invSlots[i].transform)
                         {                            
                             int childCount = child.transform.parent.childCount;
 
                             if(childCount < 5)
                             {
                                 if(child.transform.name == "inv_Stick")
                                 {
                                     Vector3 childPos = child.transform.position;
                                     Vector3 transPos = transform.position;
 
                                     transform.parent = invSlots[i].transform;
                                     transPos = childPos;
                                     //transPos.x = childPos.x +1;
                                     itemPlacedInStack = true;
                                     return;
                                 }
                             }
                         }
                     }
                 }
Comment
Add comment · Show 1
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 Fornoreason1000 · Oct 25, 2014 at 02:42 AM 0
Share

do you want to offset each individual stick? or you are you going for a $$anonymous$$e craft style storage(after 64 stick a new stack gets created?). OR like other RPS one a stack reaches its maximum reject any new additions? its hard to make out what your trying to do.

anyway the general idea is to collect all of your items into of an array(I'm assu$$anonymous$$g its invSlots) then run a loop to the amount of items in the inventory... each loop, you want to do whatever is needed, if your items don't stack you can offset it each loop, if they don't, only offset it every X times... making sure that you check that your adding the correct items to the stack( you can't have a stick and a bean bag in the same stack)

could you tell me in greater detail what you want help with?

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

28 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

guiText/GameObject position 2 Answers

[Closed]transform.position not updating fast enough 0 Answers

Spawn gameObjects at random locations in limited area 4 Answers

How to instantiate controller at specific rotation (Error: It is not possible to invoke an expression of type 'UnityEngine.Quaternion' 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