05-01-2021, 11:40 AM
I'm trying to change buoyancy for each particle to make them move upward.
I used user data and map Buoyancy to one of the slots, but when I change the value nothing happens to particles.
Here is part of my code:
Could you please help me?
I used user data and map Buoyancy to one of the slots, but when I change the value nothing happens to particles.
Here is part of my code:
Code:
void Start()
{
solver.OnCollision += Solver_OnCollision;
emitter.OnEmitParticle += Emitter_OnEmitParticle;
}
void Emitter_OnEmitParticle(ObiEmitter em, int particleIndex)
{
int k = emitter.solverIndices[particleIndex];
Vector4 userData = emitter.solver.userData[k];
userData[0] = solver.buoyancies[k];
emitter.solver.userData[k] = userData;
}
private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
foreach (Oni.Contact contact in e.contacts)
{
if (contact.distance < 0.01f)
{
var col = world.colliderHandles[contact.other].owner;
var userData = solver.userData[contact.particle];
if (evaporators[0].collider == col)
{
userData[0] = 0;
}
solver.userData[contact.particle] = userData;
}
}
}
Could you please help me?