So this is for unity an ai scrip using Random to find 2 different results but its giving me the error cs0104 which is
"an ambuiguous reference between 'UnityEngine.Random' and 'System.Random'
and I'm not quite sure how to fix this... it may just be me working on it too long my brain is fried but ... man this is the code I'm working with
private void SearchWP()
{
float rndmZ = Random.Range(-wPointRange, wPointRange);
float rndmX = Random.Range(-wPointRange, wPointRange);
wPoint = new Vector3 (transform.position.x rndmX, transform.position.y, transform.position.z rndmZ);
if (Physics.Raycast(wPoint, - transform.up, 2f, theGround))
wPointSet = true;
}
CodePudding user response:
The error simply means you have both
using UnityEngine;
using System;
on top of your file which allow you to address the types included in these namespaces directly without everytime having to address them by the full namespace type name.
However, as the error tells you both namespaces contain a type called Random, System.Random and UnityEngine.Random so the compiler does not know which one you want to refer to.
From your usage it looks like you want to use UnityEngine.Random.
So you can do that by addressing it via the full namespace
float rndmZ = UnityEngine.Random.Range(-wPointRange, wPointRange);
float rndmX = UnityEngine.Random.Range(-wPointRange, wPointRange);
or by putting a
using Random = UnityEngine.Random;
on top of your file
