• 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 daytripper1989 · Aug 02, 2012 at 03:25 PM · gameobjects

gameObject comparison

if(other.transform.position == brickList[r].transform.position)

other is a Collider object while brickList is an array of gameobjects but in different position.. i want to know the index of other in the array..

but the if statement never returns true.

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 Julien-Lynge · Aug 02, 2012 at 03:47 PM 0
Share

@daytripper1989,

Your post (as it appears now) probably isn't appropriate for UnityAnswers. As a general rule, posts should probably have the following:

  • One clear question (what, specifically, are you trying to do?)

  • Relevant background information (what have you already tried? what other things might be important for us to know?)

  • Context information (what do you expect to happen? What is happening ins$$anonymous$$d?)

  • Your request (what specifically do you expect of the UnityAnswers community? Are you looking for links to relevant information, a chunk of code that you can use, ...?)

If your post is one of the following, you should consider changing it or asking on the forums ins$$anonymous$$d:

  • A one- or couple-sentence post, especially with a broad question ("how do I make a game like Halo?") or no discernible question ("WebPlayer doesn't allow me to save to disk"). We'll need more specific information to help you.

  • Asking the opinion of the community ("Best method to store files?"). $$anonymous$$uch better to discuss these on the forums.

  • A question that focuses on the end result, rather than anything technical ("how do I make a laser beam?"). These mean that you probably haven't done enough research. If you're just starting out and don't even know where to look, try searching here, the forums, and Google first and then posting your question to the forums. The Unity resources are a great place to start (http://unity3d.com/support/resources/). When you get to a more technical point ("how do I adjust the color of a line renderer for a laser beam?") we can probably help you.

  • A disjointed or incomplete question ("How do I make a jumping enemy? Physics doesn't look right."). It will help us if you take a moment to add some context information, background, and general explanation.

  • Copying your code verbatim with a one-line question like "why doesn't this work?" or "what is wrong with my code?" To the community, this sounds like you came across an error, spent 0 time trying to fix it yourself, and simply posted it in the hope that someone else would do your work for you.

  • Asking how to make a complete game ("How do I make $$anonymous$$inecraft in Unity?"). Creating a game is a monumental task and not something we can impart to you in 500 words or less.

Finally, make sure that you check to see if your question has already been answered here, and do a quick google search, before posting a new question.

Of course, the members here are awesome folks and will probably try to help you anyway - hopefully you'll get an answer or some helpful comments. If not, now you know why.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hathol · Aug 02, 2012 at 05:29 PM

A possible cause (aside from "the position is not in the array") for this might be floatingpoint inaccuracy (a.k.a. the bane of gamedevelopers). What you could do, is try and compare the distance between the positions with a very small number to check if the positions are at least very close together if not equal.

 if((other.transform.position - brickList[r].transform.position).magnitude <= .01f)
 {
     // do something
 }
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 daytripper1989 · Aug 02, 2012 at 11:27 PM 0
Share

thanks a lot mate..

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Find gameobjects by tag, and destroy if in the distance of a certain game object... 1 Answer

Grouping GameObjects by script 1 Answer

Empty Parent GameObject Moving with Child 1 Answer

How to get all the GameObjects positions into a .txt file? 2 Answers

How do I instantiate gameObjects? 2 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