private void PlaceInfluencer(GameObject influencer) { //Call influence display update at end //make a ray from the mouse ray = overheadCamera.ScreenPointToRay(Input.mousePosition); LayerMask layerMask = ~(1 << 2); //cast a ray and check if it is valid if (Physics.Raycast(ray, out hit, 1000, layerMask) && (hit.transform == terrain.transform || hit.transform == bridge.transform)) { //get location for the map array manipulation Vector2 hitLocation = new Vector2(hit.point.x, hit.point.z); //manipulate the coordinates into mapData coordinates int xLoc = (int)(hitLocation.x + (x / 2)); int yLoc = -1 * (int)(hitLocation.y - (y / 2)); //validate the coordinates if (xLoc >= 0 && xLoc < x && yLoc >= 0 && yLoc < y && mapData[xLoc, yLoc]) { //create a world location from the mapData coordinates Vector3 placementLocation = new Vector3(xLoc - (x / 2) + .5f, hit.point.y, -yLoc + y / 2 - .5f); //create the new influencer GameObject tempInfluencer = Instantiate(influencer, placementLocation, Quaternion.identity); //set the influencer's stored coordinates to be used in the influence map creation Influencer tempInf = tempInfluencer.GetComponent <Influencer>(); tempInf.SetMapLocation(xLoc, yLoc); //if it is set to green team if (team) { tempInfluencer.transform.parent = GreenTeamParent.transform; InfluenceMap.Instance.AddGreenUnit(tempInf); } //else it is set to red team else { tempInfluencer.transform.parent = RedTeamParent.transform; InfluenceMap.Instance.AddRedUnit(tempInf); } } } InfluenceMap.Instance.gameObject.GetComponent <InfluenceMapDisplay>().UpdateDisplay(); }