Need help with tower defense game

Hey guys, I'm fairly new in coding in c#, and I am making a Tower Defense game, but my problem is that I can build an x amount of turrets on 1 place, and don't know how to prevent a player from doing so.

this is my code

using UnityEngine; using System.Collections;

public class Buildplace : MonoBehaviour {

public GameObject towerPrefab; 

void OnMouseUpAsButton() {

GameObject g = (GameObject)Instantiate(towerPrefab); g.transform.position = transform.position + Vector3.up; Debug.Log("Mouse Up"); } 


How would I be able to see if there is a turret placed on my "buildplace", and if there is, deny any other entry for building one on that spot?

by oosterdijk via /r/csharp

Leave a Reply