So I’m trying to get a ball to spawn at a random location at the top of my 9:16 screen in my 2D game in Unity, but this code is giving me some compiler errors. The compiler errors involve mainly the 26th line (the instantiate line with the random.range code). The first one tells me that the expression denotes a type, where a variable, value, or method group was expected. The second one says that no overload for method ‘Instantiate’ takes ‘2’ arguments. Any ideas on how to fix this? Here is my code:
using UnityEngine;
using System.Collections;
public class Spawning : MonoBehaviour
{
public GameObject ball;
public GameObject platform;
public float spawnRate;
public int ballCount;
public int platformCount;
public bool ability;
void Start () {
spawnRate = 0;
ballCount = 1;
platformCount = 1;
ability = true;
}
void Update () {
spawnRate += Time.deltaTime;
if (spawnRate == 20 && ability == true) {
Instantiate (ball, Vector3 (Random.Range (0, 16), Random.Range (7, 9), Quaternion.identity));
spawnRate = 0;
ballCount += 1;
}
}
}