|
| 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 |
|
|
|
| 05 Nov 2011 03:11 AM |
| what and wheres the problem? |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 1231 |
|
|
| 05 Nov 2011 03:45 AM |
| Better in what way, though? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 05 Nov 2011 03:56 AM |
| I'm trying to simulate Newton's law of Gravitational Attraction. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 05 Nov 2011 04:09 AM |
| that sounds like it will look amazing, have you tried using magnitude? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 05 Nov 2011 04:11 AM |
| could you use gravitational attraction to make a mario galaxy style game? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 05 Nov 2011 04:16 AM |
oh...
could you use magnitude to make a mario galaxy style game though |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 05 Nov 2011 06:04 AM |
| The video has uploaded to my account (TheQwerty1806), hopefully it will help. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|