I’ve been using VerletPhysics2D for a project, and have some questions about interactions between particles and behaviors.
I’ve studied the VerletPhysics example Attraction2D. When a particle p is added, to prevent collisions, a new AttractionBehavior is also added to the “world” physics; from the example:
physics.addBehavior(new AttractionBehavior(p, 20, -1.2f, 0.01f));
So this “force field” follows the particle p as it moves, which is what we want. (The example doesn’t add the same behavior to the particle p.) Hence, when I check the list of behaviors for p, p.behaviors.size() is zero. (But physics.behaviors.size() includes the new AttractionBehavior, of course.)
In this case, when I look at the object p, is there a way to figure out that it has associated with it this AttractionBehavior? Without adding code that adds the same AttractionBehavior to p?
I’m a bit confused; the AttractionBehavior force field is clearly in physics (I can see it when I check physics.behaviors), but I don’t seem to be able to see the AttractionBehavior when I look at particle p.
(Reason why I’m interested in this detail: my project involves multiple clusters of particles and behaviors that are dynamically created. It’s helpful for me to be able to keep track of particles/behaviors, grouped according to the clusters they belong to. I can do this manually with extra lists, but am wondering if there’s a more elegant way just through the library.)
Thanks!