Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  how to change the fluid into Granular in game?
#1
Corazón 
I want to change the obi fluid to the Granular when some triggers are matched(to simulate the situation when the water meet lava), but every time when it happens, unity will crash. I wanna know how to solve this problem, or a better way to change a fluid particle to the granular.
Really thank you guys  Sonrisa Sonrisa Sonrisa Corazón

Here is my code about this change:

void LateUpdate()
{
if (!isActiveAndEnabled)
return;

for (int i = 0; i < solver.particleToActor.Length; ++i)
{
if (solver.particleToActor[i] != null)
{
if (solver.userData[i].x < 1f && solver.userData[i].x > 0.1f)
{
KillParticle(i);
}
}
}

}

private void KillParticle(int index)
{
ObiEmitter emitter = solver.particleToActor[index].actor as ObiEmitter;
emitter.GetComponent<ObiParticleRenderer>().render = true;
emitter.EmitterMaterial = new ObiEmitterMaterialGranular();
}
Reply


Messages In This Thread
how to change the fluid into Granular in game? - by ElaBosak - 08-01-2021, 11:47 AM