Okay, basically what I have going on is i need to set a bool on a script, that is attached to a prefab(gameobject). Problem is the script is on every prefab that the player can use. So I have to save myself future trouble when the player does end up having another said prefab(gameobject) with that script. So boiling it up I need to set a bool on a script that is attached to the array of gameobjects.
Here is what I figured it would be like, well for one object but of course I need to able this to a whole array:
saidObject.GetComponent<SaidScript>().saidBool = false;
//With an obvious else doing
saidObject.GetComponent<SaidScript>().saidBool = true;
If the bool is either going to be true for all objects or false for all objects, you could use a static variable
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
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.
Answers and Comments
361 People are following this question.
How Can i Get This bool to work? Just need someone willing to explain.
how to instantiate an object from an array above the previously instantiated object from the same array?
Help with Enemy death Animation!
ScreenToWorldPoint error (C#)
I need help with code for audio file.