Universe particle simulator

Hello,

I’m making a Universe Particle Simulator (not a game) in unity3d. I have a map of the universe how it was in the beginning, and I place spheres everywhere like a grid. Now the spheres have to attract each other. The heavier ones are moving slower to the other spheres and the lighter ones are attracting each other faster. So you get a simulation of the universe somehow. Here’s a tutorial on youtube in adobe after effects, but I want to give it a try in unity3d. My question is: how do I let the particles attract eachother like in the tutorial? Hope for your help :smile:

Read up on the n-body problem and its associated algorithms. The Wikipedia article is a good place to start…

Yeah that’s what i’m meaning. But how do I use that in Unity3d? There must be a script that gives particles density and let them attract other particles…

There will be such a script when you write it…

You can probably pull something like this off easier than what that big calculus theorem on the wiki page might insinuate. In fact you will probably have to come up with a clever, highly optimized, algorithm to handle that many points anyways.

You could maybe do something like, have an array of points, each point stores it’s size and position.

Iterate through the array and for each point, lerp it towards every other point by a value of the other points density divided by it’s distance. Maybe put a limit radius on how far points have to be from each other for the lerp operation to occur.

This may not be as accurate as the theorem on the wiki page, but it would probably produce something that looks like the effect.

Ok I give it a try. Maybe I can look further on the forum for scripts like I need.

Just a suggestion, I don’t know if this would be better as I haven’t tested anything, but rather than each point checking how much IT should move towards all other points, instead you are probably better off using a Sphere Collider and using it as a trigger, OnTriggerEnter(), add force proportional to that objects size to any object entering the Collider.

That way you only have to read data from your point array when you actually need it.