Im trying to get it so when i “spawn fish” it checks my UI text that shows the money to see if there is enough money for the “fish price” but “coin amount seems to be a bool? even though its showing integers?”
public class FishSpawner : MonoBehaviour
{
public Vector3 center;
public Vector3 size;
public GameObject Fishprefab;
public int fishPrice;
// Start is called before the first frame update
void Start()
{
SpawnFish();
SpawnFish();
}
// Update is called once per frame
public void Update()
{
Debug.Log(ScoreTextScript.coinAmount);
if (Input.GetKeyDown(KeyCode.Q))
SpawnFish();
}
public void SpawnFish()
{//was working on this trying to get it to talk to the UI
if (ScoreTextScript.coinAmount =+ fishPrice);
Vector3 pos = center + new Vector3(Random.Range(-size.x / 2, size.x / 2), Random.Range(-size.y / 2, size.y / 2), Random.Range(-size.z / 2, size.z / 2));
Instantiate(Fishprefab, pos, Quaternion.identity);
public class ScoreTextScript : MonoBehaviour
{
Text text;
public static int coinAmount;
private void Start()
{
text = GetComponent<Text>();
}
public void Update()
{
text.text = coinAmount.ToString();
}
}