Script B (attached to many objects) references Script A (just one exists, attached to Object A). Object A is not often active in hierarchy, so when Script B tries to Find Object A with tag in the Awake() function, it often fails due to Object A's active status. I thought about making a function like Code (CSharp): void FindObjectA() { objectA = GameObject.FindGameObjectWithTag("A"); } that is called every time I need to reference it Code (CSharp): if (objectA != null) FindObjectA(); But that seems like a REALLY BAD solution. Assigning the gameobject in the inspector is not an option.
Yeah, just do it in a sane manner, you can use everything in a wrong way. I never had a real probkem with them.
Find Object by tag is bad practice? What about transform.Find() for children? What should I do instead when I need to find Object(s) in my scene Hierarchy?
Right now I'm declaring variables and only using those Find functions on Awake at the start of the scene, then referencing the variable to execute the code For example: Code (CSharp): NewTimerScript myTimer; void Awake() { myTimer = transform.Find("Timer Holder").GetComponent<NewTimerScript>(); } void OtherFunctionsInThisScriptThatReferenceTheTimer() { myTimer.ThanksForYourHelpGuys(iReally, appreciate, it); } Is this a bad way of going about this?