# Applying two forces to particles

**URL:** <https://discourse.processing.org/t/applying-two-forces-to-particles/6127>\
**Category:** Coding Questions\
**Created:** [November 30, 2018, 8:12pm UTC](https://discourse.processing.org/t/applying-two-forces-to-particles/6127 "2018-11-30T20:12:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmean](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jmean](https://discourse.processing.org/u/jmean)\
**Post date:** [November 30, 2018, 8:12pm UTC](https://discourse.processing.org/t/applying-two-forces-to-particles/6127/1 "2018-11-30T20:12:42Z")

</div>

Hi,

I’m writing a sketch where I want many small particles to be attracted to large central particle, this is working.  
However I also want all small particles to repel from each other at the same time.

I’ve tried a couple of things and am getting erratic results.

here’s the: [https://codepen.io/jmean/pen/Eebzvq](https://codepen.io/jmean/pen/Eebzvq) if anyone’s willing to give me any pointers.

Thanks

---

<div class="post-metadata">

**Author:** ![dan850](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@dan850](https://discourse.processing.org/u/dan850)\
**Post date:** [December 1, 2018, 1:51am UTC](https://discourse.processing.org/t/applying-two-forces-to-particles/6127/2 "2018-12-01T01:51:31Z")

</div>

You may want to check out this Particle Attraction and Repulsion Forces Tutorial - [https://www.youtube.com/watch?v=OAcXnzRNiCY](https://www.youtube.com/watch?v=OAcXnzRNiCY)
