/// <summary> /// Attempts to place the selected object at the given vector3 click point on the grid. /// </summary> /// <param name="clickPoint">The point on the grid of the mouse click</param> private void PlaceSelectedObjectAt(Vector3 clickPoint) { //set the z to 0f clickPoint.z = 0f; //get the target cell from world point location CustomGridCell targetCell = grid.GetGridCellInGrid(clickPoint); //if the target cell is inside the grid and it's empty, place object if (targetCell != null && !targetCell.IsOccupied) { grid.SetGameObjectInGrid(targetCell, SelectedObject, IsFlipped); } }