• 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 El Maxo · Mar 05, 2015 at 02:20 PM · gameobject.tagnotworking

"GameObject.FindWithTag" Working with one scene but not another

Hi guys,

I feel something strange is happening in one of my projects, I have this code bellow that works on one scene but not another, the one it doesn't work in is my main scene (and yes I have both tags). I'm not sure quite what to do, or if i'm doing something wrong, I have tried rolling multiplier in one room so that might be it, any suggestions please help.

 using UnityEngine;
 using System.Collections;
 
 public class testytest : MonoBehaviour {
     public GameObject map;
     // Use this for initialization
     void Start () {
         map = GameObject.FindWithTag("Map");
     }
     
     // Update is called once per frame
     void Update () {
         
     }
 }
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
1
Best Answer

Answer by MIkeross3 · Mar 06, 2015 at 02:11 AM

I may be mistaken but isn't it

 map = GameObject.FindGameObjectWithTag("Map");
 
 

even so, I prefer to use layers. String methods as above are not suggested for performance

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 meat5000 ♦ · Mar 06, 2015 at 02:25 AM 0
Share

Nope :)

http://docs.unity3d.com/ScriptReference/GameObject.FindWithTag.html

It's FindGameObjectsWithTag ($$anonymous$$ultiple)

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

21 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

Related Questions

Detect a gameObject's tag via OnCollisionEnter() 5 Answers

IOS Gun shooting script 1 Answer

Null reference error can u help me to fix it ....! 0 Answers

PC build crashing on launch everytime 1 Answer

Trying to make the enemy fire 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges