Using arrays and for loop with GetComponent error

var Enemy : int;
var dusman : int[,];
var Probab : int;
for (var i = 1; i< 6 ; i++)
for (var j = 1; j< 6 ; j++)
dusman[i,j] = Enemy*.GetComponent(EnemyScript).Probab[j];*

  •  }*


This is the code I use for defining spawn probabilities for enemies. I got 5 prefabs of enemy and all have “Probab1”,“Probab2” … to 5. I want to assign those numbers to “dusman” so for example it will be like dusman12 1 means first prefab and 2 means Probab2. I use 5 different probability variables for 5 different time/level.
But I got this error when I try to compile :
‘GetComponent’ is not a member of ‘Object’
I also assigned 5 prefab as collider to player object which includes these codes. Which defined as Enemy1,Enemy2,Enemy3.
Can anaybody help me where is the problem ? Thank You…

You define your Enemy as an integer at the beginning of your script. You cannot use GetComponent on an int.

It needs to be a GameObject.

And I’m not totally sure what you’re trying to accomplish. You want to spawn random enemies?

From what I gather, you would want to do something like (sorry, can only do it in c#)

public GameObject[] Enemies;
public Vector2[] Probability; //With a high and a low number

public GameObject GetEnemyToSpawn()
    Random rnd = new Random();
    int percent = rnd.Range(0, 101);

    for (int i = 0; i < Probability.Length; i++)
        if (percent <= Probability_.x && percent >= Probability*.y) // If percentage is within the specified range*_

return Enemies