Hey Guys,
Im currently stuck on a small issue where i have a bunch of enemy objects that rush towards the player character and try to attack the player. The player is able to shoot and kill the attacking enemies.
Currently ive got my enemies spawning with random colours, though the prefab has a preset material set to it. Code for enemy spawning is below:
//Spawn the enemy at the center of the plane
Enemy spawnedEnemy = Instantiate (enemy, spawnTile.position + Vector3.up, Quaternion.identity) as Enemy;
//Spawn and enemy with a random colour
spawnedEnemy.GetComponent<MeshRenderer>().material.color = new Color(Random.Range (0f, 1f), Random.Range (0f, 1f), Random.Range (0f, 1f), Random.Range (0f, 1f));
So for example if i start the game one of the enemies could be blue and the other could be green.
Ive currently got a particle system in place that activates on the death of the enemy. So once the enemy dies it blows up into small cubes.
I was just wondering how i can change the colour of the explosion for each enemy based on the random colour that theyre instantiated with.
For example if i killed a blue enemy then the partical system would emit blue cubes, if the enemy was green then the particle system would emit green cubes.
Thanks!