Hello Everyone, i have a question about scripts say i have a shooting script used by a few different guns and the guns are on a switch script so that only one gun it active at once. and i have an animation and i want to have an if statement that if the gun is out of bullets it doesn’t play. i want to make this animation script modular so i can use it for every gun so i cant just make another var with the guns clip size is there a way to access a variable in the script as a component instead of the actual script in the scene window?
p.s sorry about all the useless info i didn’t know if it’d help or not
If I understand you want to access a variable from another script inside a second script? Correct?
If it’s so, you will use:
scriptame.varname: where “scriptname” is the name of the script containing the variable you want and the “varname” is the wanted variable…
Something like:
If (GunScript.magazineBullets == 0) allowedToShoot = false;
thats alot like what i want and thank you for responding but i knew how to do that but this script is used by every weapon i have basically what i should be asking is would it still work if the script is being used by more than one object with different vars for each because i dont think it will