Question by
IIPusheenII · Apr 17, 2018 at 12:35 PM ·
instantiateprefabspawnmouseclickonmousedown
Instantiate PreFab on trigger location
I'm trying to make little buildings pop up und triggers I put in my scene when they are clicked on. When clicked again the upgraded version of the building is supposed to replace it.
Basically what I need is for the buildings to spawn un top of the trigger wich lies flat on a plane, and for the buildings to replace each other if "upgraded".
I just started and have no idea of how to write in c# so please excuse my almost non existing code...
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CityTrigger : MonoBehaviour {
public GameObject[] buildingPreFabs;
private void OnMouseDown()
{
int i=0;
Instantiate(buildingPreFabs[i]);
i++;
}
}
Comment