Spawning objects at the same location

Hello, I’m new to scripting in Unity and I would like to create a SpawnPoint that randomly spawns objects at the same location (I must set the size and put the gameobjects that I want to randomly spawn, that would be awesome) to that position and in x amount of the time it respawns again and again…

var Object : GameObject;
    var SpawnPoint : GameObject;
     
    InvokeRepeating("SpawnEnemy", 5, 10);
     
    function SpawnEnemy()
    {
        Instantiate (Object, SpawnPoint.transform.position, Quaternion.identity);
    }

I just need the randomly spawning objects. Thanks!

(1) Vars should be lowercase.

(2) InvokeRepeating should be in a start function or a condition that gets called once when u need it.

(3) The second param of InvokeRepeating can hold a Random Range (eg) InvokeRepeating(“FunctionName”, 5, Radom.Range(min, max));

(4) Use a local var before Instantiate to assign your object too, then tweak the size/scale

(eg) UnTested

var obj = object;
obj.localScale.x = 0.5;
Instantiate(obj, transform.position, transform.rotation);

I meant to spawn different kind of objects (like if I put some prefab it spawns that prefab, but I can but as much prefabs as I want so they can randomly spawn).

To spawn a random prefab you need to make an array of game objects to pull from. Then use the Random function to randomly grab a game object from your list and then spawn it from your spawn point.

public GameObject[] enemies;

void Spawn(){
int randomEnemy = Random.Range(0, enemies.Length);

Instantiate(enemies[randomEnemy, spawnPoint.transform.position, transform.rotation);
}

It says some errors :frowning:

Which ones?

Assets/Spawning2.cs(1,25): error CS0116: A namespace can only contain types and namespace declarations

Assets/Spawning2.cs(7,5): error CS8025: Parsing error