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
1
Question by JKLs · Dec 05, 2011 at 03:56 AM · gameobjecttagfindaccess

Whats the best way to access other Game Objects?

There are many ways to access other game objects in unity. I think using tag is the easiest way for me because I dont need to pay attention to the object's hierarchy. But it may take cost compared to other ways.

http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Could you tell me your opinion about this?

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 milali · Dec 05, 2011 at 04:04 AM 0
Share

sorry to be a stickler, this is more a question and answer place than a forum, best to stick this discussion thread on the forum :)

As for what this is talking about, you just use objects as the 'pointer' to them

avatar image syclamoth · Dec 05, 2011 at 04:13 AM 0
Share

Tags can be slow, but you can use them if there's only one object you need to get at a time. Otherwise, just do it the usual program$$anonymous$$g way- keep references to all the objects you want to have access to, and pass them around in code. That's the fastest way (much better than using string lookups, which is what tags are).

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by suruz@kento · Dec 05, 2011 at 06:32 AM

If you consider object lookup performance in runtime then using fixed referenced object in inspector is the best choice .In that case unity has early bound reference to the object which does not suffer from enumeration cost. For that reason, using GameObject.find(...) in Update() is worst way to go.

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 DGArtistsInc · Dec 05, 2011 at 04:05 AM

Well i have used several ways to access Game Objects and it depends on the situation there is no better way of doing it. Tags access the whole game object/s and Get Component accesses a script/component from a certain Game Object.

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

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

6 People are following this question.

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

Related Questions

GameObjectWithTag Child 1 Answer

Finding class where current GameObject is assigned to as a var 1 Answer

All the objects in my script choose the same target. 2 Answers

Access a child from the parent or other gameObject. 2 Answers

Find all gameObjects with same tag 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