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 » Scripters
Home Search
 

Re: Gravitational physics

Previous Thread :: Next Thread 
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Jul 2011 01:27 PM
I made a physics engine 'cus I was bored. Test it here. You can turn on/off collision by saying "collision"
http://www.roblox.com/Orbital-physics-testing-item?id=31314964

Here's the source:

for _, v in ipairs(workspace:GetChildren()) do
if v:findFirstChild("Force") then
v.Parent = workspace.Game
end
end

local slow = 3
local collision = true

game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
if msg:lower() == ("collision"):sub(1, #msg) then
collision = not collision
end
end)
end)

-- Physics engine
while wait() do
for _, a in ipairs(workspace.Game:GetChildren()) do
if a.Name ~= "Part2" then
a.CFrame = a.CFrame + a.Force.Value/slow
for _, b in ipairs(workspace.Game:GetChildren()) do
if a ~= b then
if (a.Position - b.Position).magnitude < (a.Size.X/2 + b.Size.X/2) and collision then
local fa, fb = a.Force.Value, b.Force.Value
if b.Name ~= "Part2" then
a.Force.Value, b.Force.Value = fb*(b.Size.X/a.Size.X), fa*(a.Size.X/b.Size.X)
else
a.Force.Value = a.Force.Value + CFrame.new(b.Position, a.Position).lookVector*(a.Force.Value.X^2 + a.Force.Value.Y^2 + a.Force.Value.Z^2)^(1/3)
end
a.CFrame = b.CFrame + CFrame.new(b.Position, a.Position).lookVector*(a.Size.X/2 + b.Size.X/2)
end
a.Force.Value = a.Force.Value + CFrame.new(a.Position, b.Position).lookVector/math.max((a.Position - b.Position).magnitude/2, 1)/slow*(b.Size.X/a.Size.X)
end
end
end
end
end
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Jul 2011 01:40 PM
Now steal my physics engine and make something more interesting out of it.
Report Abuse
Megolas is not online. Megolas
Joined: 16 Jan 2011
Total Posts: 357
19 Jul 2011 02:02 PM
Say, i thought about it, we could use the 2 formulas:
1) X = X0 + V0t + 0.5at^2
2) v = V0 + at

to make a non lagging physics engine, but when something fall, how do we calculate how far will it bump up? (i the material changes it, but still, how?)
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
19 Jul 2011 03:19 PM
Elasticity.
Report Abuse
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
19 Jul 2011 04:51 PM
Fail planets...
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
19 Jul 2011 04:57 PM
Trivial physics. YOU should make them work as boxes, not spheres.
Report Abuse
Megolas is not online. Megolas
Joined: 16 Jan 2011
Total Posts: 357
20 Jul 2011 08:05 AM
... i knew that - but what is the formula to calculate how far will it jump?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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