- Home /
Telling the difference between static variables being pulled from several scripts of the same name on different objects.
I have several objects that I need to pull info from when I am holding them but the scripts that control the movement are all the same name. So the other script I have pulling the static variables from the BeingHeld script on the objects are receiving all of the variables from all of the scripts it seems like. Is there a way to differentiate which variable is coming from witch object?
Answer by NoseKills · Jun 14, 2017 at 03:47 PM
Not sure if i understand you correctly... Static variables exist per class, not per instance of a class like non-static ones.
So if you have a static variable in a class that you have attached onto multiple objects, there is still only one of that variable. That's exactly what static does.
If you need several objects of the same type to hold different values in their variables, those variables can't be static.