How do I get my game to generate a random number for each counter,how do I make my game generate 2 different numbers at the same time
How do I make my game generate 2 different numbers on the counters? I can get 1 counter to work but on the other one stays at zero even when I attach it to the script itself. Do I have to make a separate code for the other counter? here's my code so far
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class UiController : MonoBehaviour { public Text CountersText;
private int counter;
void Start()
{
counter = 0;
}
// Update is called once per frame
void Update()
{
}
public void OnQuitButtonClick()
{
Application.Quit();
}
public void OnRollButtonClick() { int roll = Random.Range(1,14); counter=roll; CountersText.text = counter.ToString();
}
}
I tried adding it to a separate component as well and that did not seem to work either.
Answer by BenWiller1989 · Sep 04, 2020 at 02:15 PM
I don't even know, what that is. So we are talking about integers used as counters. These are "counter" and "roll"? You have to be more specific! Which counter stays zero or are you talking about two different script components?