I was using this code in unity 2D:
float nilaiRandom;
void Start()
{
nilaiRandom = Random.Range(1.11f, -1.88f);
transform.position = new Vector2(transform.position.x, nilaiRandom);
}
Unity count Error it says: Assets\\Go.cs(14,23): error CS0104: 'Random' is an ambiguous reference between 'UnityEngine.Random' and 'System.Random'
What actually happened to my unity and what is the solution? please help me
.Net comes with System.Random
and Unity comes with UnityEngine.Random
. If you have both using System
and using UnityEngine
then there is ambiguity between them. Qualify the name to disambiguate:
UnityEngine.Random.Range(1.11f, -1.88f);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.