private void CreateGround() { bool[,] res = DrawCircle(spawnPosX, spawnPosZ, 18); for (int j = 0; j < mapSize * 2; j++) { for (int k = 0; k < mapSize * 2; k++) { if (res[j, k]) { Transform placedObj = Instantiate(masterGroundTile.GetTransform(), new Vector3((j * distanceScale) + masterGroundTile.XOffset, yOffset, (k * distanceScale) + masterGroundTile.ZOffset), Quaternion.identity); placedObj.tag = "Ground"; placedObj.SetParent(parent.transform); if (j < mapSize - 1 && k < mapSize - 1) { map[j, k] = masterGroundTile; isGroundMap[j, k] = true; } } } } bool[,] res2 = DrawCircle(spawnPosX, spawnPosZ, 25); for (int j = 0; j < mapSize * 2; j++) { for (int k = 0; k < mapSize * 2; k++) { if (res2[j, k] && isGroundMap[j, k] == false) { Transform placedObj = Instantiate(masterGroundTile.Beach, new Vector3((j * distanceScale) + masterGroundTile.XOffset, yOffset, (k * distanceScale) + masterGroundTile.ZOffset), Quaternion.identity); placedObj.tag = "Beach"; placedObj.SetParent(parent.transform); if (j < mapSize - 1 && k < mapSize - 1) { map[j, k] = masterGroundTile; isGroundMap[j, k] = false; } /** * START */ ////Oriantate towards heightpoint //Vector3 heightPointPosition = new Vector3(75, 10, 75); //float distance = Vector3.Distance(placedObj.transform.position, heightPointPosition); ////Move //float yPosition = heightPointPosition.y - distance / 5.55f; //placedObj.transform.position = Vector3.MoveTowards(placedObj.position, heightPointPosition, 8f); //placedObj.position = new Vector3(placedObj.position.x, yPosition, placedObj.position.z); ////Rotation //Vector3 targetDir = heightPointPosition - placedObj.transform.position; //Vector3 newDir = Vector3.RotateTowards(placedObj.transform.position, targetDir, 3.5f, 0.0f); //Vector3 rotation = Quaternion.LookRotation(newDir, placedObj.up).eulerAngles; //placedObj.eulerAngles = rotation; ////Scale to fill empty space //placedObj.transform.localScale = new Vector3( // placedObj.transform.localScale.x + (distance * distanceScaleValue.x), // placedObj.transform.localScale.y + (distance * distanceScaleValue.y), // placedObj.transform.localScale.z + (distance * distanceScaleValue.z)); //float newDistance = Vector3.Distance(placedObj.position, heightPointPosition); //if(newDistance < beachMinDistance) //{ // Destroy(placedObj.gameObject); //} /** * END */ } } } }