Hi,
With this code: (GameObject.FindWithTag("go").SetActive (false));
I can successfully disable the gameobject “go” which is a child object of the player but it doesn’t work the other way around.
If the Game Object “go” is disabled from the start and I use (GameObject.FindWithTag("go").SetActive (true));
it doesn’t do anything and the missing Debug Log is proof of that. My question is why? and how do I enable the Game Object “go” after finding it with tag when it’s disabled from start?
To specify, it’s a collision trigger, here’s the full code:
void OnTriggerEnter(Collider target)
{
if (target.tag == "Player")
{
GameObject.FindWithTag("go").SetActive (true);
Debug.Log("Wheel oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOn");
}
You need a reference to the object as findwithtag will only find objects which are active.
1 Like
Okay that makes sense. Thank you
Okay so I’ve encountered a problem: Since it’s a multiplayer game with ten players that all instantiate at the same time and the collider that is supposed to activate the child object (a wheel) on only the player that enters the box, the script that I have on the box in the level cannot reference children of objects that havent spawned yet…
I hope this makes sense. I’m unable to reference the gameobject that I want to activate OnTriggerEnter, because the instantiated clone version of said object, doesn’t exist yet. How can I reference the instantiated version of the gameobject, so that the trigger box knows what gameobject to activate in game?
Nevermind I figured it out I simply do the activation code from the player instead of the trigger box. Easy peasy