Assets\Scripts\MonsterSpawner.cs(30,34): error CS1501: No overload for method 'Range' takes 3 arguments I am getting this erorr and not able to understand how to fix it. It will be great if any would of you could help me

Roopjot Kaur Gandhi 1 Reputation point
2022-02-02T07:22:39.353+00:00

public class MonsterSpawner : MonoBehaviour
{
[SerializeField]
private GameObject[] monsterReference;

private GameObject spawnedMonster;

[SerializeField]
private Transform leftPos, rightPos;

[SerializeField]
private int randomIndex;
private int randomSide;

// Start is called before the first frame update
void Start()
{
    StartCoroutine(SpawnMonsters());
}

IEnumerator SpawnMonsters()
{
    while (true)
    {
        yield return new WaitForSeconds(Random.Range(1, 5));
        randomIndex = Random.Range(-1, 0, monsterReference.Length - 1);
        randomSide = Random.Range(0, 2);

        spawnedMonster = Instantiate(monsterReference[randomIndex]);

        // left side
        if (randomSide == 0)
        {
            spawnedMonster.transform.position = leftPos.position;
            spawnedMonster.GetComponent<Monster>().speed = Random.Range(4, 10);

        }
        else
        {
            // right side
            spawnedMonster.transform.position = rightPos.position;
            spawnedMonster.GetComponent<Monster>().speed = -Random.Range(4, 10);
            spawnedMonster.transform.localScale = new Vector3(-1f, 1f, 1f);

        } // while loop

    }
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,927 questions
0 comments No comments
{count} votes