Hi everyone, I am trying to get GameObjects to spawn at certain locations that I have named SpawnPoint ( they also have a spawn point tag attached to them as well) that is attached to a gameobject named SpawnController but i’m not sure how to do this I currently have some code for invoking a repeating function that spawns the gameobject but I don’t know how to change where it spawns to the Spawnpoints as it asks for a transform. Do I need to add the gameobjects to a list or an array? How would I go about doing that I’m pretty rubbish at using lists and arrays as i have no idea how to add objects to them.
Here is my code at the moment:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerUnitSpawn : MonoBehaviour
{
List<GameObject> selection;
public GameObject playerUnit;
// Use this for initialization
void Start()
{
InvokeRepeating("SpawnUnit", 1f, 5f);
}
// Update is called once per frame
void Update()
{
}
void SpawnUnit()
{
Instantiate(playerUnit, transform.position, transform.rotation);
}
}
Any help is greatly appreciated. Thanks.