im trying to make a code that grabs a random number, then takes that number and puts it into a sleep/count down timer, but everytime i try to run the code in unity it tells me i cant convert a float to an int at line 14,39. can someone help me with this? i tried making it grab a randomized number and use that number for a sleep/countdown (not an on-screen count down)
heres my code:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class RandomTimer : MonoBehaviour { public float RadNum = 0f; void Start() { RadNum = Random.Range(1000, 20000); Debug.Log(RadNum); System.Threading.Thread.Sleep(RadNum); } }
float Random.Range(float, float)andint Random.Range(int, int)(see docs.unity3d.com/ScriptReference/Random.Range.html). The compiler would pick the method based on the argument values you supplied. But then you go an assign the int result to a float variable. This is on you.