• 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 IKilledKenny_2 · Jun 02, 2015 at 10:38 PM · collisionrigidbodytransformtimetag

80 tags for one game?

Hello unity3D.I have a question about tags.Is 100 tags for a game too much?For example my game have 8 characters and each character uses that 10 tags each.If this is too much tags or should i try a different method for find objects?If anyone knows?Can you please tell me?Also what is the maximum tags a game should have?

 public var player : Transform;
 var enemy : Transform;
 var camLerpAmount : float =0;
 var cam  : Transform;
 var explosion: GameObject; 
 public var roarCamera     : Transform;
 public var mouth    : Transform;
 var GenzuPlanetRoar     : GameObject;
 var Teleport : GameObject;
 var spawn    : Transform;
 
 
 function Awake (){
 
  player = gameObject.GetComponent(Transform);
  
 }
 
 
 function Start() {
 
         player = GameObject.FindWithTag("Player").transform;
         enemy = GameObject.FindWithTag("Dummy").transform;
         cam = GameObject.FindWithTag("TaiichiCamera").transform;
         roarCamera = GameObject.FindWithTag("RoarCamera").transform;
         mouth = GameObject.FindWithTag("Jaw").transform;
         renderer.enabled = true;
         collider.enabled = true;
         
 }
 
 
 
 function OnCollisionEnter(collision : Collision){
 
 
  
 if(collision.gameObject.tag == "Dummy"){ 
 collision.transform.gameObject.animation.Play("Hit_Flying");
 collision.transform.gameObject.animation["Hit_Flying"].speed =0.00050;
 collision.rigidbody.AddForce (Vector3.forward * 2000000);
 player.transform.gameObject.animation.Play("Burn_To_Hell_Part_2");
 player.transform.gameObject.animation["Burn_To_Hell_Part_2"].speed = .25;
 camLerpAmount = Mathf.Clamp01 (camLerpAmount + 0f);
 renderer.enabled = false;
 collider.enabled = false;
 
 }
 yield WaitForSeconds(2.5);{
 cam.transform.position = roarCamera.transform.position - roarCamera.transform.forward;
 camLerpAmount = Mathf.Clamp01 (camLerpAmount + 5f);
 Instantiate(GenzuPlanetRoar,mouth.transform.position,mouth.transform.rotation);    
 cam.transform.Rotate(0,360,0);
         
                 
                     
                     
                                 
 }
 yield WaitForSeconds(2.5);{
 cam.transform.position = roarCamera.transform.position - roarCamera.transform.forward;
 camLerpAmount = Mathf.Clamp01 (camLerpAmount + 5f);
 Instantiate(Teleport,spawn.transform.position,spawn.transform.rotation);    
 
         
                 
                     
                     
                                 
 }
 
 
 
  
  
  
          
      
  
  
 
 
 
 }
 
 
Comment
Add comment · Show 4
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 devluz · Jun 03, 2015 at 12:28 AM 0
Share

Not sure if it is a problem but what are you doing with all those tags? Usually you can use GameObject.GetComponent, GameObject.GetComponentInChildren, ... and so on to find most of the things you need.

avatar image IKilledKenny_2 · Jun 03, 2015 at 12:49 AM 0
Share

well yea that too...=o.The reason for the tags is that when i start the round 1 for the first battle,player is suppose to view player 2 automatically unless theres another way of doing this

avatar image zagmodell · Jun 03, 2015 at 09:06 AM 0
Share

Why should you need 100 tags ?

avatar image IKilledKenny_2 · Jun 03, 2015 at 02:55 PM 0
Share

The reason is because i dont know how to add a transform to the object before the round starts without using findwithtag

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by LaneFox · Jun 03, 2015 at 12:58 AM

There is nothing wrong with having that many tags.

However you should consider the side effects of doing so, there is likely a better approach to your design than using 10 unique tags for each character but its impossible to give any advice on that without any code to reference.

Eventually the process of creating and maintaining them is going to be unwieldy or counterproductive. Afte rall, you're only using 100 but already asking if it is safe. In terms of performance, tags are actually pretty fast to find objects in the scene and such so it just depends on your situation.

Comment
Add comment · Show 7 · 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 IKilledKenny_2 · Jun 03, 2015 at 01:06 AM 0
Share

i put a reference up.Also would it be better if i use devluz method?

avatar image LaneFox · Jun 03, 2015 at 01:12 AM 0
Share

Yes that would be better. You could also probably reference a lot of that through the Inspector by making some of that stuff public variables ins$$anonymous$$d of finding it at runtime. If another Character needed it then you could just find it through that reference ins$$anonymous$$d of scanning the scene with a tag filter.

avatar image IKilledKenny_2 · Jun 03, 2015 at 02:56 PM 0
Share

I have tried adding the getcomponent but it still needs a tag.Is there another way of me being able to put the transforms in the inspector from the start?

avatar image LaneFox · Jun 03, 2015 at 03:26 PM 0
Share

For example Jaw is on the Prefab, correct? So why search for it at runtime? This is a useless operation, just make a public variable so it is exposed in the inspector, then drag the Jaw into the field. Now it's always known and you can reference it directly in the script.

Do this wherever possible to reduce runtime operations.

avatar image IKilledKenny_2 · Jun 03, 2015 at 04:00 PM 0
Share

Im trying to understand what your saying,with the gameObject in the inspector it works but with the transform it doesnt go in.For example.when i put the character and the object with the script in scene mode and put the transform in the inspector it works. but when i save the prefab to project folder it doesnt work.Is there a way i cang et the transform that i put in the scene into the project folder prefab?

Show more comments
avatar image
0

Answer by Duugu · Jun 03, 2015 at 06:50 PM

Using a lot of comparisons with tags imho is actually pretty slow, as string comparisons are slow at all. :)

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 ArmanOhanian · Jun 03, 2015 at 10:40 PM

I don't quite know if too many tags are bad, but I I hope this will help you tidy-up your code a bit.

Instead of coding this:

 if(collision.gameObject.tag == "Dummy"){ 
  collision.transform.gameObject.animation.Play("Hit_Flying");
  collision.transform.gameObject.animation["Hit_Flying"].speed =0.00050;
  collision.rigidbody.AddForce (Vector3.forward * 2000000);
  player.transform.gameObject.animation.Play("Burn_To_Hell_Part_2");
  player.transform.gameObject.animation["Burn_To_Hell_Part_2"].speed = .25;
  camLerpAmount = Mathf.Clamp01 (camLerpAmount + 0f);
  renderer.enabled = false;
  collider.enabled = false;
  
  }
 

I'd organize it like this:

 if(collision.gameObject.tag == "Dummy"){ 
   collission.die();
    // Then code a public die() method for whatever it is you are tagging as dummy.
 }

...then I'd code a public die() method for whatever it is I am tagging as dummy.

Comment
Add comment · Show 3 · 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 IKilledKenny_2 · Jun 03, 2015 at 11:00 PM 0
Share

Are you saying that if the object i am using to collide with the dummy gets destroyed within contact?Because im trying to get the object to find the transforms as soon as the round starts

avatar image ArmanOhanian · Jun 04, 2015 at 04:49 PM 0
Share

I am not sure what exactly you're trying to achieve. What I am observing, and I may be wrong here, is that all the code seem to belong better in your class tagged 'dummy'.

Again, I've only seen a fraction of your code and don't know your intent.

avatar image IKilledKenny_2 · Jun 04, 2015 at 10:30 PM 0
Share

No thats the whole thing.What i am trying to achieve is that i want the object to get the transform without using the FindWithTag $$anonymous$$ethod.

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

22 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

Related Questions

handling collision with two objects of the same tag 1 Answer

Make AI run from Player 1 Answer

Modifying height directly on a Rigidbody Object without gravity 1 Answer

How to properly move a rigidbody/collider? 2 Answers

Why I've a gap between meshcolliders? 0 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