[Help] How to get Color inside particleSystem.StartColor from script

Hey guys.

Iam working on my Block breaker game. Iam using the particle system like in the course, so when a brick gets “destroyed” there is a burst of particles flying around. I want the color of the particles to change accordigly to the overall color of the sprite and Iam having difficulties achieving this.

In my scripts I made SpriteHandler that takes care of delivering the right sprites to the right object in the right order. It also delivers proper sound and color, of course. There are no problems with sprites and sounds, everything works fine, after tons of Debug.Log-ing Iam sure it delivers the desired color as well, but I cannot get this color inside the game object’s particleSystem.StartColor.
I also don’t want this color in the gameObject’s sprite renderer, because I dont want it to ruin the sprite so this color is deposited in a Color variable of the gO.

This is part of my script that is attached to the game object that recieves and displays the sprites and plays the coresponding sound but it does not want to color the particles. The code is cut down for clarity:

Find code here

If I remove the last line of code everything works fine, its just that the explosions are all white. If I leave the code like this, there are no explosions at all. Ive tried everyting I could and run out of ideas. Can someone please point out what Iam NOT getting right here? I suppose this is no rocket science.

So far I’ve tried:
-Debug.Loged everything I could to make sure that the (right) color gets loged in the console and that the method GetColor() works properly
-I’ve tried using the SpriteHandler.GetColor() in the last line instead of getting the color from
SpriteHandler inside the ShowSprite and puting in in the explosionColor beforehand.
-made some more juggling with the code
-made sure the explosions weren’t happening behind the background image and couldn’t be seen.

So how do I get the StartColor to be the same as Color explosionColor?

Thank you for your suggestions,

Privacy & Terms