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 Karsnen_2 · Jun 14, 2012 at 07:29 PM · positionfunctionparentchildren

FInd the min and max position of children?

Hello,

I have four children to a parent. They all stick together wherever they go. The children are placed on the right, left, up and down with respect to the parent. Due the rotation of the parent, at any point I would like to find the child which occupies the minimum/Maximum X position and the minimum/maximum Z Position among everything.

What is the best way to solve it or is there any in-built Unity3d function which could grant access to find my child position or even compare the position with all the children and find the min and max?

Any help or advice is highly appreciated.

Thank you Devs

GAME : Top-Down View. i.e. along x and z axis.

P.S. :If you devs recommend to keep it simple, first I would like to find the min then.

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

1 Reply

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

Answer by whydoidoit · Jun 14, 2012 at 07:38 PM

Can't test this as I'm currently reimporting all my game assets :( - But this should do it:

     using System.Linq;

     var leftMost = transform.Cast<Transform>().OrderBy(t=>t.position.x).First();
     var topMost = transform.Cast<Transform>().OrderBy(t=>t.position.z).First();
Comment
Add comment · Show 18 · 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 whydoidoit · Jun 14, 2012 at 07:39 PM 0
Share

Obviously use .Last() for the maximum position.

avatar image Mizuho · Jun 14, 2012 at 07:42 PM 0
Share

Just a curiousity question but...how's the compatibility for Linq across different platforms? I've been straying away from using it because my boss wants VERY high compatibility, and I can't seem to find any nice resources detailing it.

avatar image whydoidoit · Jun 14, 2012 at 07:43 PM 0
Share

It's compatible on US and C# so long as you don't use the $$anonymous$$i mscorlib.dll

avatar image whydoidoit · Jun 14, 2012 at 07:45 PM 0
Share

See here supported on everything except micro

avatar image whydoidoit · Jun 15, 2012 at 01:59 PM 1
Share

It will work find on an iPad - it certainly does for me :)

Sorry about the x/z mix up!

Show more comments

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

5 People are following this question.

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

Collider doesn't transfer to function 1 Answer

Unity error, can't modify transform.position value 1 Answer

Variables Set by Function Outside of Script 1 Answer

How to reduce the handheld.vibrate() 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