Im making a sim city game and I need it to where the buildings will not spawn in any game object in the game. Please help. Script is in c#
using UnityEngine;
using System.Collections;
public class MouseClick : MonoBehaviour {
public GameObject building;
public Collider coll;
void Update() {
if (Input.GetMouseButtonDown(0)) {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo = new RaycastHit();
if(coll.Raycast(ray, out hitInfo, Mathf.Infinity)){
newBuilding ( hitInfo.point );
}
}
}
void newBuilding(Vector3 Building){
GameObject building1 = (GameObject)Instantiate(building);
building1.transform.position = Building + new Vector3 (0, 0.01f, 0);
}
}