public int num;
void Start () {
num = Random.Range (1, 5);
}
When I do this, the word Random
gets colored red, and it just says:
"unknown resolve error".
Any ideas?
public int num;
void Start () {
num = Random.Range (1, 5);
}
When I do this, the word Random
gets colored red, and it just says:
"unknown resolve error".
Any ideas?
Add the following code at the top of your code
using Random = UnityEngine.Random;
Random.Range
is not part of System.Random
, it's a Unity function
First, make sure your script isn't named the same as unity's libraries and classes.
Since you use unity Random
not System.Random
, try typing the following code instead:
num = UnityEngine.Random.Range(1, 5)
You might be able to remove the UnityEngine.
if you have the following statement at the top of your code:
using UnityEngine;
If you want only the Random
class or want to resolve an Ambiguous reference you can use:
using Random = UnityEngine.Random;
Also if you use C#
's System.Random
you can use Random.Next
instead.