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: Roblox Gravity

Previous Thread :: Next Thread 
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 02:43 AM
I've managed to simulate Newtonian Gravity in Roblox, and I was wondering how I could make it even more realistic. (I know about the accelerated G.)

G = 0.0000066738480

function set_position(base)
divide = 0
parts = game.Workspace:GetChildren()
for i = 1,#parts do
local check1 = (parts[i]:FindFirstChild("ID"))
if (parts[i].className == "Part") and check1 ~= nil then
base = base + ((parts[i].Position)*parts[i]:GetMass())
divide = divide + parts[i]:GetMass()
end
end
return base/divide
end

function find_mass(base)
divide = 0
count = 0
parts = game.Workspace:GetChildren()
for i = 1,#parts do
local check1 = (parts[i]:FindFirstChild("ID"))
if (parts[i].className == "Part") and check1 ~= nil then
count = count + 1
divide = divide + parts[i]:GetMass()
end
end
return divide/count
end

while true do
wait()
d = set_position(script.Parent.Position)
r = (d - script.Parent.Position).magnitude
t = find_mass(script.Parent.Position)
script.Parent.Attraction.position = set_position(script.Parent.Position)
script.Parent.Attraction.P = G*((script.Parent:GetMass()*t)/r*r)
end
Report Abuse
pokelord910 is not online. pokelord910
Joined: 26 May 2009
Total Posts: 1045
05 Nov 2011 03:11 AM
what and wheres the problem?
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 03:25 AM
There are no problems, I just wanted to make sure this was as realistic as it can possible be. Then again, I suppose I am asking for someone with a degree in physics.
Report Abuse
penguin38 is not online. penguin38
Joined: 08 Nov 2008
Total Posts: 1231
05 Nov 2011 03:26 AM
Rofl, you're asking for realistic physics in ROBLOX?

MAYBE when it comes to gravity, but besides that, that's impossible.
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 03:42 AM
I've found that this script works quite well, I was just wondering whether it could be made better.
Report Abuse
penguin38 is not online. penguin38
Joined: 08 Nov 2008
Total Posts: 1231
05 Nov 2011 03:45 AM
Better in what way, though?
Report Abuse
pokelord910 is not online. pokelord910
Joined: 26 May 2009
Total Posts: 1045
05 Nov 2011 03:48 AM
what physics are you trying to make

cause exploiting newtonian laws would be one heck of a project
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 03:56 AM
I'm trying to simulate Newton's law of Gravitational Attraction.
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 03:58 AM
Penguin, I mean making it more realistic.

This is actually part of a bigger project, I plan on trying to form a simple solar system from a cloud of gas and dust.
Report Abuse
pokelord910 is not online. pokelord910
Joined: 26 May 2009
Total Posts: 1045
05 Nov 2011 04:09 AM
that sounds like it will look amazing, have you tried using magnitude?
Report Abuse
penguin38 is not online. penguin38
Joined: 08 Nov 2008
Total Posts: 1231
05 Nov 2011 04:09 AM
How about having different gravity attractions for every single point on each object? :3

Honestly, I don't know. I think that's pretty good already.
Report Abuse
pokelord910 is not online. pokelord910
Joined: 26 May 2009
Total Posts: 1045
05 Nov 2011 04:11 AM
could you use gravitational attraction to make a mario galaxy style game?
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 04:14 AM
I've already used magnitude to calculate the distance:

d = set_position(script.Parent.Position)

r = (d - script.Parent.Position).magnitude <-- Calculating distance.

t = find_mass(script.Parent.Position)
script.Parent.Attraction.position = set_position(script.Parent.Position)
script.Parent.Attraction.P = G*((script.Parent:GetMass()*t)/r*r)
Report Abuse
pokelord910 is not online. pokelord910
Joined: 26 May 2009
Total Posts: 1045
05 Nov 2011 04:16 AM
oh...

could you use magnitude to make a mario galaxy style game though
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 04:26 AM
In about 40 minutes my video should upload to YouTube (TheQwerty1806), then you will see why it can't be used for anything calm at the moment.
Report Abuse
qwerty1806 is not online. qwerty1806
Joined: 20 Sep 2008
Total Posts: 737
05 Nov 2011 06:04 AM
The video has uploaded to my account (TheQwerty1806), hopefully it will help.
Report Abuse
BlueCamaro60 is not online. BlueCamaro60
Joined: 15 Nov 2010
Total Posts: 35
05 Nov 2011 07:52 AM
This looks like a good script when making a Planet or something so that you cannot just walk off of it. :P Good thinking dude, I might take this script. :D
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