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 ez06 · Mar 09, 2014 at 06:52 PM · gameobjectfindgameobjectswithtag

Is FindGameObjectWithTag() too heavy on resources for 50 objects?

Hi,

I have about 50 objects to which I appended an empty child-object. I store the coordinates of the object as a tag in that child-object. The tags will be something like "1,4", "2,3", "6,1" etc...

My game will search one tag through these 50 objects every 1 second. Is this too heavy for a mobile game?

Is there an alternative to tags for my purpose? Is there a way of using integers instead of strings to make it faster?

EDIT: my 50 game objects are prefabs and appear progressively during the game. So they are not there from the start. I want to track each of these prefabs with an integer and destroy some of them at will during the game

Comment
Add comment · Show 8
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 robertbu · Mar 09, 2014 at 06:58 PM 0
Share

I predict that it is efficient enough for what you want or even if you wanted to do it every frame. But why take my educated guess? For situations like this, I just test it. Usually I keep pushing until I get a slow down. Create a sample app with with your data. Execute the code every frame. If that doesn't slow it down, start executing the code in a loop many times each frame.

avatar image getyour411 · Mar 09, 2014 at 07:07 PM 0
Share

While I agree with robertbu, I also think your design use of "tags" to store stuff like coordinates sounds funky. Why not use a List which can be iterated over?

avatar image Eric5h5 · Mar 09, 2014 at 07:13 PM 0
Share

Yes, you should re-think your design. You don't really need to use any of the Find commands more than once (in Awake/Start)...after the list is populated initially, have a system where objects register/unregister with the list as needed, so you don't need to do Find again.

avatar image Gruffy · Mar 09, 2014 at 07:34 PM 0
Share

id say, cos each time its doing all that string data parsing and I think each call is a long trudge through every object in game`s tag identifier until you find you objects in question. I wonder if it would be more productive to at first find them and populate a list with them and then you already have them set up to play with.. this would both reduce your overheads and rework probably even help to shorten your code. Ooops, sorry Eric5h5, i have just noticed you have practically said the same thing but more succinctly. doh . Gruffy :) (actually, i think there might be common trait in all the comments above here)

avatar image ez06 · Mar 09, 2014 at 08:35 PM 0
Share

Hi there, thank you for your responses. I have read some threads about lists and they seems to be a C# feature, and I am using Javascript. Also, I already have arrays for my 50 objects and they are fixed-sized. Do you think I can efficiently do the same with JS arrays or is it worth making lists in a separate C# script?

Show more comments

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

24 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

Related Questions

HELP Find gameObject With tag in another array 1 Answer

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

Is it possible to have multiple tags (or the like) on one object? 10 Answers

Scripting error message 1 Answer

Refering to gameobject script is attached to 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