# How to change an int value in the Unity editor

The player of my game can collect logs and can use them for hold on the fires. Each fire has its own status. So one is off and the other one is for 50% on.

I created a public int inside my script that is linked to my gameObject. Because it is public, I can change the value also in the Unity editor. See image:

The int is linked to a int parameter of "Intensity". And use this as follow:

public Animator anim;
public int campfireStatus;
public float timer;
public float beforeDecrease; // timer for campfires
bool inTrigger = false;

// Use this for initialization
void Start () {

anim = GetComponent<Animator>();

}

void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.tag=="Player"){
inTrigger = true;
}
}

void OnTriggerExit2D(Collider2D other) {
if (other.gameObject.tag=="Player"){
inTrigger = false;
}
}

// Update is called once per frame
void Update () {

anim.SetInteger("Intensity", campfireStatus);
//Debug.Log (campfireStatus);

if(inTrigger && Input.GetKeyDown(KeyCode.E)) {
if (WoodBehaviour.count > 0) {
campfireStatus++;
}
}

timer+= Time.deltaTime;

if (timer > beforeDecrease) {

timer = 0;

if (campfireStatus !=0){
campfireStatus--;
Debug.Log ("Decrease");
}

}

}


But the added value inside the Unity editor will not be use by the script. It will start from the default state, as you can see here:

Each transition, like the one is selected, will have the condition: intensity is equals to 1 till 4.

So I look for a solution, so that I am be able to change which start animation should fired for that object, by changing the Campfire Status inside the Unity editor with the values of 1 till 4.

• The conditional statement is equal to – Caspert Apr 3 '15 at 12:46