This script is used to place turrets on a grid of tiles. Everything works well until I place one turret. When I place one Turret it doesn’t let me place anymore, when I delete the turret while playing it will let me place one again. Any Idea why?
function Update ()
{
if(Input.GetMouseButton(0))
{
Debug.Log(“Cast Ray”);
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, hit, 100.0))
{Debug.Log("Hit");
if(hit.collider.gameObject.tag == "EmptyTile")
{
hit.collider.gameObject.tag = "FullTile";
Debug.Log("Hit Empty");
var turretPos = hit.collider.gameObject.transform.position;
Instantiate(doubleTurret,turretPos,Quaternion.identity);
}
}
}
}