Reputation: 51
I'm creating a snake game using Unity and in one part I have:
void RandomlyPlaceApple()
{
int ran = Random.Range(0, availableNodes.Count);
Node n = availableNodes[ran];
appleObj.transform.position = n.worldPosition;
appleNode = n;
}
I've already added using Random = UnityEngine.Random;
to the top of my code and no errors appear... but the apple doesn't appear either. I'm thinking something is wrong with my code but I can't find what it is.
What can I try next?
Upvotes: 0
Views: 667
Reputation: 2586
You have two Random classes available from UnityEngine namespace and System namespace. You can try removing the imports of one namespace at the top of your script, or you can just specify which random to use.
int ran = Random.Range(0, availableNodes.Count);
change to
int ran = UnityEngine.Random.Range(0, availableNodes.Count);
Upvotes: 2