08-01-2021, 11:47 AM
(This post was last modified: 08-01-2021, 12:17 PM by ElaBosak.
Edit Reason: upload related code
)
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
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();
}
Really thank you guys
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();
}