06-01-2021, 08:18 AM
(This post was last modified: 06-01-2021, 08:26 AM by josemendez.)
This is what's happening in your script:
When you emit a new particle, you store its buoyancy value in userData.
When a particle hits a collider, you set its userData to 0.
(when particles are simulated by Obi, the contents of userData are diffused)
But you never do solver.buoyancies[k] = something. So ofc, buoyancy values are never actually set to the diffused values in userData.
In the Raclette sample scene, you'll see there's a "ColorFromViscosity" component added to the emitter. In its LateUpdate() method, color is driven by viscosity, then viscosity and surface tension are set to whatever values are in userData[k][0] and userData[k][1]. That's what maps the userData values to viscosity and surface tension and that's precisely what you're missing.
To make it clear, these are the steps required:
Anytime after the simulation has taken place (that is, after FixedUpdate()), you need to copy back from userData to buoyancies. LateUpdate() is a good place.
When you emit a new particle, you store its buoyancy value in userData.
When a particle hits a collider, you set its userData to 0.
(when particles are simulated by Obi, the contents of userData are diffused)
But you never do solver.buoyancies[k] = something. So ofc, buoyancy values are never actually set to the diffused values in userData.
In the Raclette sample scene, you'll see there's a "ColorFromViscosity" component added to the emitter. In its LateUpdate() method, color is driven by viscosity, then viscosity and surface tension are set to whatever values are in userData[k][0] and userData[k][1]. That's what maps the userData values to viscosity and surface tension and that's precisely what you're missing.
To make it clear, these are the steps required:
- buoyancy ---> userData (every time a particle is emitted)
- userData undergoes diffusion (during simulation, done automatically)
- userData ----> buoyancy (after simulation) // you're missing this one.
Anytime after the simulation has taken place (that is, after FixedUpdate()), you need to copy back from userData to buoyancies. LateUpdate() is a good place.