I'm simulating gravity in space using Newton's law of gravitation.
How I'm going about it is by making a script `Gravity` that has a static list of `Gravity` classes that consists of all the objects containing the script `Gravity` in the scene.
Then I go through the list and run the function `Gravitate()` on each of them and feed into it all of the objects so that it can calculate a gravitational force for itself.
**My question is:** how do I go about this without running the same operation for each of the object that is effecting each other.
In other words, how do I calculate the force for my object, tell the other object its force as well and tell it not to run its own function as I've already calculated its force?
I thought I could somehow use coroutines for this but I'm not experienced enough. Telling the other script to skip this frame or something like that.
↧