Loading...
Logo
Processing Forum
I create my particles like this:
Copy code
  1. public void addParticle() {
  2. VerletParticle2D p = new VerletParticle2D( Vec2D.randomVector().scale( 5 ).addSelf( width / 2, height / 2) );
  3. physics.addParticle( p );
  4. physics.addBehavior( new AttractionBehavior( p, 20, attractionStrength, attractionJitter ) );
  5. }
I want to be able to change the strength and jitter values of the attraction behaviour at will once the all the particles have been created but I'm not sure how to access the particles behaviour and apply the new values, any help will be much appreciated.

I'm using toxiclibs verletphysics by the way.

Replies(1)

If you add attractionBehaviors like this it's hard to find the one you want once you need it again. So I usually extend the VerletParticle2D class to make it's attractionBehavior part of the class. That way you can always find the attractionBehavior associated with that particle later. Also see the code example I mailed you.