Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attachments Not Working - Disable/Renable?
#1
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.


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);
            }
        }
    }
Reply
#2
(27-04-2025, 09:44 PM)scoull Wrote: 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.


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);
            }
        }
    }

Hi,

Attachments aren’t designed to work with fluid. The reason is that giving infinite mass (which is how static attachments work) to a fluid particle also makes it infinitely dense. May I ask what your use case is?

Kind regards,
Reply
#3
(27-04-2025, 10:24 PM)josemendez Wrote: Hi,

Attachments aren’t designed to work with fluid. The reason is that giving infinite mass (which is how static attachments work) to a fluid particle also makes it infinitely dense. May I ask what your use case is?

Kind regards,
Hi Jose,

Thanks for the quick reply. I am working on a game where you put sauce onto objects, so I want to be able to freeze particles once they reach the object so that they don't move until killed.

I already have a solution working for this using a modification of your sleepthreshold code, freezing the particles in solver space, but this means I have to move the solver around along with the frozen particles, thus I can only have sauce frozen to one moving object at a time.

Edited to say: Issue is solved as attachments are not designed for fluids. My existing solutions works fine.
Reply