Hello , I am making a simple game in which the player have to dodge from the falling obstacles .
Its all working fine but with just adding two lines of code the prefab color become black .
if (Time.time > nextSpawnTime) {
nextSpawnTime = Time.time + spawnDuration;
// Generating randon X Pos and specific Y Pos
float randomSpawnPosition = Random.Range (-halfScreenSizeUnits, halfScreenSizeUnits);
float initiatePoint = Camera.main.orthographicSize + 2;
// Generating position for Blocks
Vector2 spawnPosition = new Vector2 (randomSpawnPosition, initiatePoint);
float randomSpawnAngle = Random.Range (-spawnAngle, spawnAngle);
GameObject newBlock = (GameObject)Instantiate (enemyPrefab, spawnPosition, Quaternion.Euler(Vector3.forward * randomSpawnAngle));
float spawnSize = Random.Range (spawnSizeMinMax.x, spawnSizeMinMax.y);
newBlock.transform.localScale = Vector2.one * spawnSize;
}
So here everything is fine . The problem is in the last two lines . If I comment these 2 lines then the prefab instantiate randomly and with its own color but if I remove the comment the prefabs becomes black . what’s the problem with that ?