Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can someone help me with the calculation to make planetary gravity?

Now, I know this is a lot to ask, but I just need a 'formula' of sorts to write the script my self, for example if I have a BodyForce in the player, what would be the best way to calculate the force on the player when walking around a planet, also this wont rotate the character, is there a way to calculate the rotation of the character using a BodyGyro while animations still play?

Thanks to anyone that help

Also, if you are unable to answer the question but know someone that can, get me in contact with them, it would be greatly appreciated.

5 comments

0

This may or may not help, but in physics, (Force = mass x acceleration) as for gravity on earth, it accelerates objects (9.81 meters per second)

0

that wasn't what I was asking for but thx

0

I meant how do I get the centre of the planet and calculate the gravity reletive to the player

0

Considering 'planet' is a BasePart, then planet.CenterOfMass should return its center. I don't know how to work out the gravity aspect of your question tho.

1 answer

✓ Accepted answer
local char = player.Character or player.CharacterAdded:Wait()
C = planet.Core.CenterOfMass
local grav = Instance.new('BodyForce')
local G = (planet.Size * player.HumanoidRootPart.Size) / (char.HumanoidRootPart.Position - C).magnitude
grav.Force = char.HumanoidRootPart.CFrame.lookVector:inverse() * G

local inAtmosphere = false

while wait(0.1) do
if (char.HumanoidRootPart.Position - C).magnitude <= 10 then
inAtmosphere = true
elseif (char.HumanoidRootPart.Position - C).magnitude > 10 then
inAtmosphere = false
end

You would need to make a core for your planet and an atmosphere. Sorry, but i couldn't figure the rotation out.

1 comment

0

This took 2 hours to make, so I hope it works

This discussion is preserved as it was. New answers, comments, and votes are closed.