Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Buoyancy diffusion not working
#2
(05-01-2021, 11:40 AM)Booyaka Wrote: 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:

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?

You don’t seem to write back any data to the buoyancies array, you’re just writing values to the userData array.

Check the Raclette sample scene for reference. You need to write the userData values back to the array you wish to use, in this case, the buoyancies array.
Reply


Messages In This Thread
Buoyancy diffusion not working - by Booyaka - 05-01-2021, 11:40 AM
RE: Buoyancy diffusion not working - by josemendez - 05-01-2021, 07:47 PM
RE: Buoyancy diffusion not working - by Booyaka - 05-01-2021, 09:37 PM
RE: Buoyancy diffusion not working - by Booyaka - 06-01-2021, 09:14 AM