generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Gravity System

Previous Thread :: Next Thread 
yoyoman2 is not online. 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
TheOneSwordfighter is not online. TheOneSwordfighter
Joined: 18 Feb 2013
Total Posts: 212
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 is not online. 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
TheOneSwordfighter is not online. TheOneSwordfighter
Joined: 18 Feb 2013
Total Posts: 212
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 is not online. 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 is not online. 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
TheOneSwordfighter is not online. TheOneSwordfighter
Joined: 18 Feb 2013
Total Posts: 212
30 Apr 2013 01:28 PM
Okay, you can move two things in the same for loop! Calm yourself.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image