我正在使用Unity创建蛇游戏,而我有一个方面:
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, can someone please help me out?
编辑:对不起,但是由于某些原因,标签只会让我放unity3d,如果您没有寻找,对不起。
您可以从UnityEngine命名空间和System命名空间中获得两个Random类。您可以尝试删除脚本顶部的一个名称空间的导入,也可以仅指定要使用的随机名称。
改成