You use a 10x larger gravitational constant for the star than the home planet? You should reflect this by giving the star a 10x greater mass (custom value 4). G should be the same for both.
Although I haven't gotten it to work properly in testing. Just need to make it print out some numbers to make sure things are working as intended. And disable CollideBounce.
Doesn't seem to work at all for me. Must be something else interfering, or units not being placed into groups correctly.
Note:
Custom value 4 represents the unit's mass
DistanceSquared is a custom function that uses the distance formula, but without the square root. This is more efficient than squaring the square root.
It does this: c^2 = a^2 + b^2
Return (X of position of Unit1 - X of position of Unit2)^2 + (Y of position of Unit1 - Y of position of Unit2)^2
Making the gravity work would be trivial using my ApplyForcePolar (for ease) or ApplyForceCartesian (for efficiency) function from the tutorial.
What it does is applies a force over the shortest period of time (1 game loop). All you'd need to do is call it once every game loop, for each object, onto each other object (n^2 operations). This means you can't have too many units or it will get quadratically more laggy.
The amount of force is based on the distance and the object masses, as in Newton's equation.
Edit: Regarding vectors, the most effective format is X and Y (and Z if 3D) components. So if an object has an X velocity of 5.0 and a Y velocity of -2.0, then in the next game loop the object will have moved 5.0 units to the right and 2.0 units down. The functions I'm talking about simply modify these vectors using vector arithmetic and F=MA.
You're still trying to take shortcuts.
You use a 10x larger gravitational constant for the star than the home planet? You should reflect this by giving the star a 10x greater mass (custom value 4). G should be the same for both.
It should look something more like this.
Although I haven't gotten it to work properly in testing. Just need to make it print out some numbers to make sure things are working as intended. And disable CollideBounce.
Doesn't seem to work at all for me. Must be something else interfering, or units not being placed into groups correctly.
Ok, thought you were trying to make planetary systems. You can just use two groups then and the planet group pull the unit group.
Yeah distance squared isn't in the tutorial. Read the last note of my previous post. That's the whole function. Takes two units and returns a real.
It doesn't need to be a function but I tend to use it for lots of things.
Looks a little convoluted... here's what I'd do.
Add each planet to a unit group. Let's call it PlanetGroup.
This runs in a periodic trigger, which you could combine with the Move Objects trigger if you'd like.
Note:
Custom value 4 represents the unit's mass
DistanceSquared is a custom function that uses the distance formula, but without the square root. This is more efficient than squaring the square root.
It does this: c^2 = a^2 + b^2
Return (X of position of Unit1 - X of position of Unit2)^2 + (Y of position of Unit1 - Y of position of Unit2)^2
What you need for maximum realism is a physics engine.
Since you asked for a "Physics to SC2 for Dummies", I'll refer you to my tutorial which is just that.
http://www.sc2mapster.com/forums/resources/tutorials/22121-triggers-implementing-a-physics-engine/
This will also give you collision bounce effects.
Making the gravity work would be trivial using my ApplyForcePolar (for ease) or ApplyForceCartesian (for efficiency) function from the tutorial.
What it does is applies a force over the shortest period of time (1 game loop). All you'd need to do is call it once every game loop, for each object, onto each other object (n^2 operations). This means you can't have too many units or it will get quadratically more laggy.
The amount of force is based on the distance and the object masses, as in Newton's equation.
Edit: Regarding vectors, the most effective format is X and Y (and Z if 3D) components. So if an object has an X velocity of 5.0 and a Y velocity of -2.0, then in the next game loop the object will have moved 5.0 units to the right and 2.0 units down. The functions I'm talking about simply modify these vectors using vector arithmetic and F=MA.