02-11-2021, 02:44 PM
(This post was last modified: 02-11-2021, 02:49 PM by josemendez.)
(02-11-2021, 02:35 PM)ProDea Wrote: So is it something like this?
This gives me the correct color which is 0,1,0 Green in that case. But GetComponent calls so much. Is it actually the most optimized way to get particle color or am I missing something over here?
Your code is correct, fluid color in your case comes from the particle renderer. Particles are all white, so:
fluidColor = renderer color * particle color = (0,1,0) * (1,1,1) = (0,1,0).
(02-11-2021, 02:35 PM)ProDea Wrote: I tried this too but it gives me 1,1,1 White color. I have fluid renderer in the scene on MainCamera and (On ObiEmitter object) Obi Particle Renderer has green color 0,1,0.
Yes, this is correct and to be expected. Your particles are completely white, and being tinted green by the ObiParticleRenderer just before rendering.
If you set the ObiParticleRenderer white and your ObiEmitterShape green, then the emitted particles will be green, and tinted white like so:
fluidColor = renderer color * particle color = (1,1,1) * (0,1,0) = (0,1,0).
This would allow you to get rid of the GetComponent<> calls entirely. Note in your first script you could just cache the component if you wanted, no need to call GetComponent for every single contact like that.