27-04-2025, 09:44 PM
Hi All, thanks in advance for taking a look.
I am working with attachments for the first time using Obi Fluid. I am able to create the attachment with a proper target and particle group, but when adding particles to the particle group, nothing happens.
Additionally, if I try to disable/reenable the attachment at runtime (which I don't even think is necessary if I'm just adding/removing particles), then unity crashes and gives the GPU error "Failed to present D3D11 swapchain due to device reset/removed". I am using compute backend.
I am working with attachments for the first time using Obi Fluid. I am able to create the attachment with a proper target and particle group, but when adding particles to the particle group, nothing happens.
Additionally, if I try to disable/reenable the attachment at runtime (which I don't even think is necessary if I'm just adding/removing particles), then unity crashes and gives the GPU error "Failed to present D3D11 swapchain due to device reset/removed". I am using compute backend.
Code:
void Solver_OnCollision (ObiSolver solver, ObiNativeContactList contacts){
for(int i = 0; i < contacts.count ; ++i)
{
//Get properies of the particle in the contact
int particleIndex = solver.simplices[contacts[i].bodyA];
ObiSolver.ParticleInActor pa = solver.particleToActor[particleIndex];
ObiParticleAttachment attachment = pa.actor.gameObject.GetComponent<ObiParticleAttachment>();
ObiParticleGroup group = attachment.particleGroup;
//Changing the collision index of the particle so that it won't collide anymore
//In preparation for attaching to object
solver.filters[particleIndex]=ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, (1 << 1));
//Add particle to attachment group between emitter and object
if(!group.ContainsParticle(pa.indexInActor)){
group.particleIndices.Add(pa.indexInActor);
attachment.particleGroup=group;
Debug.Log("Attachments count " + attachment.particleGroup.Count);
}
}
}