# Artificial Gravity

So, I’ve been searching for a way to make my own Artificial Gravity. I’ve thought of many methods, and I have multiple problems. The first problem that I encountered is that Workspace Gravity doesn’t really feel like Space Gravity. It is all wacky, It feels like your on earth but you float which is not what I’m looking for. I can probably get away with it if I use Custom Cameras, and other methods to make that space feel. If anybody has any idea of methods with Custom Character Controllers and other Artificial Space Feel Gravity, please list them below.

My Second Problem is that I need a way to make the player have Gravity inside of space ships. I need to find a way to do this without altering Workspace Gravity for everyone. I was thinking of using Body Gyros and a Custom Character Controller for this but I don’t even know where to start. If you guys can help me down below that will be great.

Here are some of the articles that I have looked at:

Another thing is that I have never done physics math before. If you guys can link some resources to help me understand the math that involves custom gravity then feel free to do it.

Thanks, a bunch - Zentuz.

6 Likes

For this you can use LocalScripts conbinate with Remotes Events or simply LocalScripts. With the LocalScript the Gravity will be only alterate for the LocalPlayer, you or another Player, THE Player that Play the Game and not everyone.

Space Gravity is 0, if i think right?

Edit1:

1 Like

By workspace gravity, I mean that your character still sits in a up or down position but I can fix that by adding rotation and a body gyro to the player.

1 Like

The problem with Workspace gravity is that your character has an up or down feel to it. In space, you could move across all axis. I have to script a custom character controller if I want to move all Axis. I am looking for a better alternative but It seems like this is the only solution that I have found so far.

I also want a way to have Gravity feel like space but slow. Another problem that came up is that I want it to feel slow but when I jump, for example, I shoot up into the sky.
https://gyazo.com/3f88dbf7dea0bcbdfab9d66f77453379

Another, problem that I have is that I want the player to be able to shift Axis when he steps off the edge, I have no idea on how to solve that problem.
https://gyazo.com/35dc90f574047072389327f03989c601

Ok, i have look for a bit and i think(i am not sure) thet i can help you. All what you need is physic.

Solution Number 1 (Calculate the gravitationfield of a Ball shaped BasePart)

This will only work for a Ball shaped Part (a Planet).
If you are use a Ball shaped Baseplate, a Planet, then you should calculate this 3 Numbers, first you need the radius of you ball. This is relative easy. Resolve this equation: `r = Size/2`. Ok, lets find us the second value, the Mass. Its very simple. Just use the `BasePart:GetMass()` Function or resolve the Mass equation. I have found a arleady resolved and to Roblox studio adapted Function (by Egomoose):

``````local function getMass(size, material)
-- mass = volume * density
local volume = size.x * size.y * size.z
local density = PhysicalProperties.new(material).Density
return volume * density
end
``````

Finaly we need the Gravitationkonstant and we can calculate the Gravitationfield of your Planet and then put it into the workspace.Gravity:
The GravitationKonstant is: `6.67408 * 10 ^ -11`

The we can put this in the equation!

G = Gravitationkonstant*((Mass*1)/r^2)

Just adappt it to RobloxStudio and we are done!

``````local P = YourPlanet
local Gk = 6.67408 * 10 ^ -11
local Mass = P:GetMass()
local r = P.Size/2
local function CalculateTheGravitationfield(p, m, r, g)
return g*((p:GetMass()*1)/r^2)
end
print(CalculateTheGravitationfield(P, Mass, r, Gk))
``````

Finish! We can optimaze the code by manually calculate all values (example we can remplace the function BasePartt:GetMass)

``````local function getMass(r, material)
-- mass = volume * density
local volume = 4/3*math.pi*r^3
local density = PhysicalProperties.new(material).Density
return volume * density
end

local P = YourPlanet
local Gk = 6.67408 * 10 ^ -11
local r = P.Size/2
local Mass = getMass(r, P.Material)

local function CalculateTheGravitationfield(p, m, r, g)
return g*((p:GetMass()*1)/r^2)
end
print(CalculateTheGravitationfield(P, Mass, r, Gk))
``````

Remember that this will only work for Ball Shaped Parts.

1 Like

Use you can simply use BodyVelocity.

2 Likes

You may want to check this out.

Seems to be what you are looking for!

1 Like

That solves a few of my problems. I just need to figure out how I’m going to alter it and add low space gravity movement then I have exactly what I’m looking for.

2 Likes

If you are using 0 gravity, maybe also lower jump power to a more realistic number?

2 Likes

I should also do that but right now, I’m trying to test out Ego-moose’s controller.

1 Like

If you have read the Article inside the Link, then you know that space `SpaceGravity ≠ 0`, but a very slow Number.

@ZentuzFrost, will you make a Artificial Gravity for a Block Shaped BasePart or for a Ball Shaped BasePart (For the Baseplate or for a Planet)??

1 Like

I solved everything! Thanks abunch.

2 Likes