Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to prevent granular from colliding with themselves
#2
(20-11-2023, 03:25 AM)huangfeihu Wrote: How to prevent the granular themselves from colliding and only collide with the set layer

Hi!

By default granulars always collide with themselves, that's what makes them granulars. Otherwise they'd just be "expensive particles".

If you want to disable granular self-collisions however, you can modify their phase flags upon emission:

Code:
void Awake()
{
    GetComponent<ObiEmitter>().OnEmitParticle += Emitter_OnEmitParticle;
}

void Emitter_OnEmitParticle (ObiEmitter emitter, int particleIndex)
{
    if (emitter.solver != null)
        {
                int solverIndex = emitter.solverIndices[particleIndex];
                
                var group = ObiUtils.GetGroupFromPhase(emitter.solver.phases[solverIndex]);

                // set flags to zero instead of ObiUtils.ParticleFlags.SelfCollide
                emitter.solverphases[solverIndex] = ObiUtils.MakePhase(group, 0);
    }        
}

kind regards,
Reply


Messages In This Thread
RE: How to prevent granular from colliding with themselves - by josemendez - 20-11-2023, 06:50 AM