Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi Solver OnCollision
#4
(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.
Reply


Messages In This Thread
Obi Solver OnCollision - by ProDea - 02-11-2021, 01:34 PM
RE: Obi Solver OnCollision - by josemendez - 02-11-2021, 01:51 PM
RE: Obi Solver OnCollision - by ProDea - 02-11-2021, 02:35 PM
RE: Obi Solver OnCollision - by josemendez - 02-11-2021, 02:44 PM
RE: Obi Solver OnCollision - by ProDea - 02-11-2021, 03:06 PM