20-11-2023, 06:50 AM
(This post was last modified: 20-11-2023, 06:51 AM by josemendez.)
(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,