I made a code to random spawn a prefab on scene, was a simples code, and its giving an error, I saw on Unity Documentation and it’s the SAME CODE !
ERROR: RandomSpawn.cs(17,76): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement,
The error is on Instantiate
My code:
class RandomSpawn : MonoBehaviour
{
public GameObject[] spawn;
public void Start()
{
}
public IEnumerator Generate()
{
yield return new WaitForSeconds(1);
Vector3 position = new Vector3(Random.Range(-10.0F, 10.0F), 0, Random.Range(-10.0F, 10.0F));
Instantiate(spawn, position, Quaternion.identity) as GameObject;
}
}
Unity Link code HERE