Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi Solver OnCollision
#3
Pregunta 
So is it something like this?

Code:
private void OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        var world = ObiColliderWorld.GetInstance();
        foreach (Oni.Contact contact in e.contacts)
        {
            if (contact.distance < 0.01)
            {
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;

                if (col.CompareTag("Detect"))
                {
                    int particleIndex = _obiSolver.simplices[contact.bodyA];
                    ObiSolver.ParticleInActor pa = _obiSolver.particleToActor[particleIndex];
                    ObiEmitter emitter = pa.actor as ObiEmitter;
                    Color color = emitter.GetComponent<ObiParticleRenderer>().particleColor;
                   
                    Debug.Log(color);
                }
            }
        }
    }

This gives me the correct color which is 0,1,0 Green in that case. But GetComponent calls so much. Is it actually the most optimized way to get particle color or am I missing something over here?

I tried this too but it gives me 1,1,1 White color. I have fluid renderer in the scene on MainCamera and (On ObiEmitter object) Obi Particle Renderer has green color 0,1,0.

Code:
private void OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {
        var world = ObiColliderWorld.GetInstance();
        foreach (Oni.Contact contact in e.contacts)
        {
            if (contact.distance < 0.01)
            {
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;

                if (col.CompareTag("Detect"))
                {
                    int particleIndex = _obiSolver.simplices[contact.bodyA];
                    ObiSolver.ParticleInActor pa = _obiSolver.particleToActor[particleIndex];
                    ObiEmitter emitter = pa.actor as ObiEmitter;
                    Color color = pa.actor.GetParticleColor(particleIndex);
                   
                    Debug.Log(color);
                }
            }
        }
    }
Reply


Messages In This Thread
Obi Solver OnCollision - by ProDea - 02-11-2021, 01:34 PM
RE: Obi Solver OnCollision - by josemendez - 02-11-2021, 01:51 PM
RE: Obi Solver OnCollision - by ProDea - 02-11-2021, 02:35 PM
RE: Obi Solver OnCollision - by josemendez - 02-11-2021, 02:44 PM
RE: Obi Solver OnCollision - by ProDea - 02-11-2021, 03:06 PM