How to create a rainbow effect (Like Star Power in Mario)

Hey guys,

I’m really new to unity and I’m trying to create a rainbow effect for my player object when he picks up a powerup. This is the code I have now.

void ActivateRainbowPowerup()
	{
                // Player color is a material that I render on the player object in void Update()
		PlayerColor = rainbowPowerupMaterial;
		PlayerColor.color = Color.red;
		PlayerColor.color = Color.blue;
		PlayerColor.color = Color.green;
		PlayerColor.color = Color.yellow;
		PlayerColor.color = Color.cyan;
		PlayerColor.color = Color.magenta;
	}

I call this function in void FixedUpdate() for the duration of the powerup.

The result is that the playerobject changes to magenta. I don’t know if there is a way to put a small delay in between each line or something but as far as I can tell there isn’t.

If anybody has any suggestions I would really appreciate it.

Thanks,
Tucker

FixedUpdate is only for physics. You can use a coroutine; see Fade, specifically the Colors function which cycles through an array of colors.

–Eric