Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 6 years ago

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.

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) VRGamez 27 — 6y
0
that wasn't what I was asking for but thx SynthetickDev 188 — 6y
0
I meant how do I get the centre of the planet and calculate the gravity reletive to the player SynthetickDev 188 — 6y
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. Le_Teapots 913 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
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.

0
This took 2 hours to make, so I hope it works 222ono222 47 — 6y
Ad

Answer this question