Ray SendLight = GameObject.Find("Kamera").GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(SendLight, out Block, 3))
{
Vector3 BuildPos = Block.point;
var PosX = Mathf.Round(BuildPos.x);
var PosY = Mathf.Round(BuildPos.y);
var PosZ = Mathf.Round(BuildPos.z);
var BlockExists = false;
GameObject[] GrassBlocks = GameObject.FindGameObjectsWithTag("Grass");
foreach (var item in GrassBlocks)
{
if (PosX == item.transform.position.x & PosY == item.transform.position.y & PosZ == item.transform.position.z)
{
BlockExists = true;
}
}
if (!BlockExists)
{
GameObject Obj = Instantiate(Grass, transform.position, transform.rotation);
Obj.transform.rotation = new Quaternion(0, 0, 0, 0);
Obj.transform.position = new Vector3(PosX, PosY, PosZ);
}
}