Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by liormalichi · Feb 25, 2019 at 09:02 AM · strange ioc

*Suddenly* GameObject does not contain a definition for 'FindGameObjectWithTag'

Hi,

First time posting question.

Yesterday after programing in unity, suddenly appeared in the console 73 errors.

Most of them was GameObject does not contain a definition for 'FindGameObjectWithTag' -

In addition there were these errors:

GameObject does not contain a definition for 'Find'. GameObject does not contain a definition for 'SetActive'.

Been working this game for month!. I have to get your help!!

Thanks.

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 xxmariofer · Feb 25, 2019 at 09:47 AM 0
Share

can you share your code? can you try adding UnityEngine. in the findobjectrwithtag lines? like this

 UnityEngine.GameObject.FindGameObjectWithTag(""); 

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by xxmariofer · Feb 25, 2019 at 10:27 AM

hello, if that solved some errors is because you have created a class called GameObject that is overrdiding unity implementation. if you didnt have any errors before i would sugest searching for that class (is as easy as remove the UnityEngine. that i suggested and right click and go to implementation there will be probably your custome class or a class from a plugin) or just search in the assets folder.

Comment
Add comment · Show 2 · 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 liormalichi · Feb 25, 2019 at 10:36 AM 0
Share

Thank you!!!

avatar image xxmariofer liormalichi · Feb 25, 2019 at 10:54 AM 0
Share

i will change it to an answer for future readers with the similar issues so you can change it to correct answer.

avatar image
0

Answer by liormalichi · Feb 25, 2019 at 10:16 AM

HI,

Thank you for replying!

Adding "UnityEngine" solved some of the problem' it solved the part of FindGameObjectWithTag("") and Find().

still have errors related to GameObject such as:

FindGameObjectsWithTag (Objects in plural)

and SetActive()

in this code even if I add UnityEngine before FindGameObjectsWithTag (Objects in plural) it does not work.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 
 public class obstacleMovement : MonoBehaviour
 {
     public Rigidbody2D rb;
     public GameObject[] obstacle;
     public Vector3 playerPosition;
 
     public Vector3 Movement = new Vector3(0, 0, 0);
     private Vector3 dir = new Vector3();
     private float repelRange = 6f;
     private Vector2 repelForce;
     public Vector2 newPos;
 
     public float speed;
     public float maxDistanceFromPlayer;
     
 
 
     void Start()
     {
         speed = UnityEngine.GameObject.Find("gamemanager").GetComponent<gameManager>().speed1;
         maxDistanceFromPlayer = UnityEngine.GameObject.FindGameObjectWithTag("obstacle").GetComponent<ObstacleSpawning>().radius * 2.5f;
 
     }
 
     // Update is called once per frame
     void FixedUpdate()
     {
 
 
         //Movement = Vector3.MoveTowards(transform.position, playerPosition, 10 * Time.deltaTime);
         //Movement = new Vector3(Movement.x, Movement.y, 0f);
         //rb.MovePosition(Movement);
         obstacle = GameObject.FindGameObjectsWithTag("obstacle11");
         playerPosition = UnityEngine.GameObject.FindGameObjectWithTag("Player").transform.position;
         Vector2 repelForce = Vector2.zero;
 
 
         foreach (GameObject obstacle1 in obstacle)
         {
             dir = rb.transform.position - obstacle1.transform.position;
             Vector2 dir1 = dir;
             if ((obstacle1.transform.position - rb.transform.position).magnitude <= repelRange)
             {
                 repelForce += (rb.position - (Vector2)obstacle1.transform.position).normalized;
             }
 
             if ((playerPosition - obstacle1.transform.position).magnitude >= maxDistanceFromPlayer)
             {
                 Destroy(obstacle1);
             }
 
         }
 
         Vector2 dirr = ((Vector2)playerPosition - (Vector2)rb.position).normalized;
         float rotateAmount = Vector3.Cross(dirr, transform.up).z;
         float turnSpeed = 200f;
 
         Vector2 newPos = transform.position + transform.up * Time.fixedDeltaTime * speed;
         newPos += repelForce * Time.deltaTime;
         rb.MovePosition(newPos);
         rb.angularVelocity =-rotateAmount * turnSpeed;
 
 
         //following script lines make the game harder
         //they make enemies faster but spawn them farther away
 
     
 
 
 
     }
     
 
 }
 
 
 
 
 
 
 
 






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

166 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 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 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 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 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 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 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

None of the scripts are working after I reinstall Unity3D , how can I solve it? 0 Answers

HELP...I CANT SELECT OBJECTS! when there is a water plane in the scene (active) 1 Answer

Smoke once every week or once every 2 weeks for the past 3 month not heavy at all could I get clean in 2 weeks?normal weight 0 Answers

Buildings snap to terrain 0 Answers

Someone tell me how I can sign in same each time. 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