Easy question, but pretty difficult to figure out the answer despite modest unity knowledge.
I have a scene with a few ‘master gameobjects’, each with the same script that holds game state variables, but with different values.
master1GO <= variable 1 = "a", variable 2 = "b", variable 3 = "c"
master2GO <= variable 1 = "d", variable 2 = "e", variable 3 = "f"
master3GO <= variable 1 = "g", variable 2 = "h", variable 3 = "i"
Then spontaneously, these gameobjects will get duplicated by the scene, up to several hundred times, with their transforms roughly randomized for scattering the things clones around.
The problem is, each instance will hold its very own game state, with its own script instance, while my problem is that I need a -single- script behind all the ‘clone’ instances of the same script, since I’d like to change only the “original” gamestate in master1GO, for example, and thus alter the same values in all “master1GOclones”, and this is why I can’t however use a static reference, since I have a random number of masterGOs with the same script of course.
Is there a way to achieve such result?
I basically need to instantiate a clone of an existing gameobject, and then to substitute the cloned object script of one specific class with the original script’s reference of the same class.
thanks