Accessing variable from another class gives initial value

Hi,
my problem is fairly simple: whenever I access a variable from another script, I only ever receive the value that I originally assigned to that variable. Here’s my code:

public class PickupScript : MonoBehaviour {

public int progress = 0;
private CreatureNav script;

void Start () {
    script = new CreatureNav ();
}

void Update () {
	if(condition){
                progress=1;
            }
}
public int getProgress(){
	return progress;
}

}

public class CreatureNav : MonoBehaviour {

private PickupScript script;

void Start () {
	script = new PickupScript ();
}

public void Update () {
	if (script.getProgress () == 1) {
		RenderSettings.fog = true;
	}
}

}

The most anoying bit is that I don’t get any kind of error message, it just doesn’t work! My intent is to create fog when “condition” is met, but nothing happens. I’ve done some bug checks, and “getProgress()” always returns 0. Accessing int “progress” directly using “script.progress” also turns up as 0. Can someone please explain what’s going on?!

The problem is that the
script = new PickupScript ();
Method instantiates a new instance of the script, unrelated to the one attached on the gameobject (which I assume is the one you want to use). So instead you need to change the code :
from

void Start () {
    script = new PickupScript ();
}

to

void Start () {
    script = GetComponent<PickupScript> ();
}