12-12-2024, 11:34 AM
(10-12-2024, 11:47 AM)josemendez Wrote: Hi Alice,Thank you for the answer, but unfortunately all of this work is lost.
The following code is unnecessary, and may lead to incorrect behavior as it resets the state of the rope every time you attach a particle:
Code:actor.solver.RemoveActor(actor); // Refresh the actor in the solver
actor.solver.AddActor(actor);
Debug.Log("Actor re-added to solver.");
What this does is take out all particles and constraints from the solver and reorder all other actor's data (which is expensive), then re-add the actor using the data stored in the blueprint. Adding attachments at runtime does not require doing this.
Additionally you're adding new particle groups to the blueprint:
Code:actor.blueprint.AppendNewParticleGroup("GraspedParticles");
but never deleting them. This might not be a problem but over time can add up to a significant amount of scriptable objects being created.
Also keep in mind that having multiple attachments on the same particle will yield undefined behavior as warned in the manual. Your code does not check whether the particle about to be attached is already attached, so in case both left and right hands grasp the same particle you'll be in trouble:
kind regards,
yesterday my laptop crashed while the simulaiton was running and now seems like the simulation is not able to run anymore without continous lags.
I created another simulation that would have the same objects and behaviours but when I imported obi and used the same exact codes nothing was working anymore.
the behavior of the elastic is totally different even if i keep the same values of the characteristics. Now when i grasp it the grasped particle is visually detached from the grasping point and the elastic "updates" when i grasp it, by fastly appearing and disappearing. the code is exactly the same as the one i provided you before.