I’m looking to spawn objects randomly inside a room. I’m quite a novice and i’ve searched for bit and heres what I have. The way i want it to work is that I have gameobjects set and a picker collects one from the list of game objects and places the gameobject it got into the room.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PcPartsGenerator : MonoBehaviour
{
GameObject spawnPoints;
GameObject currentPoint;
int index;
// Start is called before the first frame update
void Start()
{
spawnPoints = GameObject.FindGameObjectsWithTag(“points”);
index = Random.Range(0, spawnPoints.Length);
currentPoint = spawnPoints[index];
print(currentPoint.name);
}
// Update is called once per frame
void Update()
{
}
}