This is my code
using UnityEngine;
using System.Collections;
public class Craft : MonoBehaviour {
public int wood = 0;
public int metal = 0;
public int iron = 0;
public int ShortSword = 0;
public int LongSword = 0;
public bool craftStart = false;
public float Timer = 0;
public bool craftReady = false;
void OnGUI(){
if (GUILayout.Button("Craft Short Sword")){
shortSword();
}
}
void shortSword()
{
craftStart = true;
if(wood >= 5 && metal >= 5)
{
if(craftReady == true){
wood -= 5;
metal -= 5;
ShortSword += 1;
Debug.Log ("You've successfuly crafting a Short Sword!");
}
}else{
Debug.Log ("Not Enough Resources.");
}
}
// Update is called once per frame
void Update () {
if(craftStart == true){
Timer += 1;
if(Timer == 50){
craftStart = false;
craftReady = true;
}
}
}
}
When I press the “Craft Short Sword” button it start the Timer and when the Timer = 50 it change the “craftReady = false” to True and when the “craftReady” equals True it’s supposed to do
if(craftReady == true){
wood -= 5;
metal -= 5;
ShortSword += 1;
Debug.Log ("You've successfuly crafting a Short Sword!");
}
but it does nothing… How do I fix this?