Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Feref2 · Nov 08, 2018 at 12:54 AM · id

Generate a unique id for a pair of objects

So I need to get all objects in between other objects, which come in pairs, left and right objects. That´s easy, is just comparing positions. The problem is that when more than one pair of objects is active, one left can be interpreted as the left of the wrong right, and viceversa. In most cases I don´t know how many objects will be there, so basically am asking if there´s a way of identifying these pairs of gameObjects, like with an id or something like that; then do something only if both have the same id.

Comment
Add comment · Show 2
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 Matt1000 · Nov 08, 2018 at 01:17 AM 0
Share

I'm sorry I couldn't get the idea of the what you want the script to do...

avatar image Feref2 Matt1000 · Nov 08, 2018 at 01:59 AM 0
Share

Sorry, it´s clamping the scale of a single/group of grounds if there´s a rigidbody in between 2 baseObjects, left and right. The scale of the ground below decreases and stops when that happens; but this can be happening multiple times in the same level, which means that sometimes this affects some incorrect grounds. (The affected ground is between leftA and rightA, not, for example, leftA and rightB).

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Nivbot · Nov 08, 2018 at 05:40 AM

Are they instantiated? When I need to reference a list of instantiated objects I normally keep track of how many there are and just rename them by the number there are. ie. if there are 21 then when you instantiate a new pair they will be LeftObject_22 RightObject_22. Sometimes I use a for loop. It just depends on what you need.

 GameObject LeftObj = (GameObject)Intstantiate(Resources.Load("whatever"));
 
 currentCount++
 
 LeftObj.name = "LeftObject_" + currentCount.ToString();


might not need .ToString() but I normally put it anyway. I've noticed before that not using it didn't throw an error but I do it just to be safe.

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
avatar image
0

Answer by Matt1000 · Nov 08, 2018 at 02:05 AM

You could have the baseObjects have a

 public GameObject other;  

and set it in the inspector. For example, leftA would have a reference to rightA and vice-versa. So, if your script finds leftA and a right, it should check if right is the same as leftA.other.

Hope it helps ;)

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 Feref2 · Nov 08, 2018 at 02:15 AM 0
Share

Thanks, but it´s more complicated than that. The rigidbodies can be arranged in different ways, so the other isn´t constant.

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

95 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 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 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

GetInstanceID ?????? 2 Answers

Is SystemInfo.deviceUniqueIdentifier reliable? 1 Answer

How to set component ID when adding it to the inspector? 0 Answers

How to use GUIUtility functions? 1 Answer

ID or name for Instantiate prefab 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