Bug / Crash how to change the fluid into Granular in game? - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html) +--- Thread: Bug / Crash how to change the fluid into Granular in game? (/thread-2690.html) |
how to change the fluid into Granular in game? - ElaBosak - 08-01-2021 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(); } RE: how to change the fluid into Granular in game? - josemendez - 08-01-2021 By changing the emitter's material every time a particle is killed, you're generating an endless loop since changing the material for the whole emitter will kill all particles and replace them with granular particles. No wonder Unity crashes . You can't change fluid into granulars at runtime or vice-versa. They're simulated in completely different ways. You can however change the properties of these fluid particles to make them resemble solid particles. For instance, you can force their position, and/or set their smoothing radius to 1. RE: how to change the fluid into Granular in game? - ElaBosak - 08-01-2021 (08-01-2021, 12:20 PM)josemendez Wrote: By changing the emitter's material every time a particle is killed, you're generating an endless loop since changing the material for the whole emitter will kill all particles and replace them with granular particles. No wonder Unity crashes .Hey, thank you soo much . so if I cant change it to granulars, how can I set the fluid most like the solid stone? If you can give me a set of those parameters, that would be better (I tried it before but it looks like a pile of jelly...). thank you again !! |