- Home /
Question by
BodaciousP · Jul 11, 2015 at 02:10 PM ·
intchanginganother script
[C#] How Can I Change A Int On A Script That Is In Multiple Objects From Another Script
I have a script named Gun and it has a int called rpm. It is in multiple objects. I want to add a number to rpm to all of the objects it is in through another script. How would I go about doing this?
Comment
Answer by Rad-Coders · Jul 11, 2015 at 07:58 PM
use static variables so in the gun script:
public class gun : MonoBehaviour {
public static int rpm;
}
and to access and use it from other scripts
public class OtherScript : MonoBehaviour {
private int otherrpm = gun.rpm;
}
Your answer
Follow this Question
Related Questions
How do I change the model for the third person controller? 1 Answer
Changing GUI texture every 3 seconds? 2 Answers
pragma strict issues with iOS 1 Answer
Animation depending on int 1 Answer
Save int value to .txt file 1 Answer