Hello, I am having a problem in regards to changing variables. The code below shows two public integer variables, missilemaxrange and missileminrange which are set by default to 20 and 10 respectively. What I would like to do is to allow the player to set a different missile that has different max and min ranges. The following is the code I have to do that.
public int missilemaxrange = 20;
public int missileminrange = 10;
void Update ()
{
if (Input.GetKeyDown (KeyCode.A))
MissileSelectA ();
}
void MissileSelectA ()
{
int missilemaxrange = 100;
int missileminrange = 20;
{
Unfortunately the code is not working. Is there something missing in my code? I’m assuming that when the player presses the A key, the missilemaxrange and missileminrange variables are set to 100 and 20 respectively. This isn’t happening, and apparently this isn’t the way to change variables from a function, so what should I have done here? many thanks!