yoyoman2
|
  |
| Joined: 07 Mar 2009 |
| Total Posts: 2170 |
|
|
| 30 Apr 2013 01:05 PM |
So, Im making a a set of functions and scripts that make gravity effects possible.
Not something too complex.
I came to an issue with efficiency though, I need Help since I came back to roblox 1 week ago after 3 years, and basiclly made everything from memory.
The problem came, when I wanted to use BodyPosition as a gravity replicator.
by making an infinite loop or an event that changes the Desired Position of the planet to the other planet when the other planet moves its position.
the only problem i have is efficiency, I came to the understanding that if I would in Theory make 2000 planets, I will have to have 2000^2 loops going all over, that seems a little extreme for a little engine that only changes the Desired Position of the BodyPosition of each planet on every other planet.
any ideas? |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2013 01:08 PM |
| Yes, make sure if a combination is tried, it won't do it again. That'll increase the speed by a lot if I understand what you are attempting to do. |
|
|
| Report Abuse |
|
|
yoyoman2
|
  |
| Joined: 07 Mar 2009 |
| Total Posts: 2170 |
|
|
| 30 Apr 2013 01:13 PM |
its very simple, each brick or "Planet" has a BodyPosition that is aimed at every other "Planet".
the problem with your idea, is that you think that i only want them to end up interacting.
but since this is a gravity system, they are both moving toward each other. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2013 01:19 PM |
Right. Why can't you move them both together in one statement?
Think of it with 2 planets. Loop over all of them:
Planet1 moves to Planet2, vice versa (one statement) Loop continues Planet2 sees it has already interacted with Planet1, ignore
You just saved 50% of your calculations about the gravity.
Now with 3. P1 goes to P2, vice versa P1 goes to P3, vice versa Loop continues P2 sees P1, ignores P2 goes to P3, vice versa
You just saved 25% of your calculations. |
|
|
| Report Abuse |
|
|
yoyoman2
|
  |
| Joined: 07 Mar 2009 |
| Total Posts: 2170 |
|
|
| 30 Apr 2013 01:24 PM |
ok.
Imagine an empty space, with 3 objects, what will happenb if object P1 moved to object P2 but P2 did not move to P1? that would be againts the laws of GRAVITY.
Im trying to make a realistic planetary system. |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 30 Apr 2013 01:27 PM |
"Empty space with 3 objects" I don't think theres any way for that to happen |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2013 01:28 PM |
| Okay, you can move two things in the same for loop! Calm yourself. |
|
|
| Report Abuse |
|
|