private void PlacePlayerOnMapAndGetInfo() { if (!flag_got_map_info) { planeInfo = FindObjectOfType<Playground>().gameObject; myMapInfo = planeInfo.GetComponent<CreateMap>(); m_enemy_i = myMapInfo.getEnemies(); myGridSize = myMapInfo.getGridSize(); myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube(); myMap = myMapInfo.GetMyMap(); //Reduce player size if player size is bigger than grid size Vector3 player_size = this.transform.localScale; if (player_size[0] > myGridSize[0]) player_size[0] = myGridSize[0] - myGridSize[0] / 10; if (player_size[2] > myGridSize[2]) player_size[2] = myGridSize[2] - myGridSize[2] / 10; this.transform.localScale = player_size; this.transform.position = LocateFirstAvailableSpace(myMap, myLocationOfFirstCube, myGridSize) + new Vector3(0f, transform.position[1], 0f); //+new Vector3(this.transform.localScale[0] / 2, 0f, this.transform.localScale[2] / 2); flag_got_map_info = true; } }