Making any object unaffected by gravity [EASY]

Hello! Welcome to my tutorial.
We are going to learn how to make any object unaffected by the gravity,
using simple physics and BodyMovers. Let’s begin!

First of all, let’s see how it looks with a gravitational impact on it:
https://streamable.com/1d9jtk
When the part is in the air, it falls down.
https://streamable.com/342ub2
We can push it, and when it has no surface to stand on, it falls down.

Why? By laws of physics, every object has a mass. Every object has a gravitational impact on another. For example, when you pick a pencil, the mass of your body is greater than the mass of the pencil, so the pencil is being pushed towards the center of you. Yet, your mass is not great enough to have much impact that we can see with our own eyes. The weight of the object is responsible for this pushing force. So now that we know why all this happens, how do we even calculate weight? Simple.
Mass * Gravity = Weight is the formula to calculate weight, really simple, and easy to remember.
So, after we know all of that, we can start by getting the necessary variables to calculate the weight.

local object = script.Parent;
local mass = object:GetMass();
local gravity = workspace.Gravity;

So, now we have all our variables. So, we’ll have to create a BodyForce inside the object.

local object = script.Parent;
local mass = object:GetMass();
local gravity = workspace.Gravity;
local bodyForce = Instance.new("BodyForce", object) -- Creating a BodyForce.
bodyForce.Force = Vector3.new(0, 0, 0) -- Setting the force to have no impact at the moment I create it.

Now, we’ll only have to give an equal force pushing the object to the opposite direction that the gravity is pushing it. In reality, weight pushes an object towards it’s center. But in Roblox, it pushes it downwards (correct me if I am wrong, did not make a research about it). So, we’ll have to pick the right axis that’s force is opposing the direction that the gravity pushes. So, we’ll need the Y axis (+).

local object = script.Parent;
local bodyForce = Instance.new("BodyForce", object) -- Creating a BodyForce.
bodyForce.Force = Vector3.new(0, 0, 0) -- Setting the force to have no impact at the moment I create it.

function set_Powers(mass, gravity)
	bodyForce.Force = Vector3.new(0, mass * gravity, 0)
end;

while wait() do
    local mass = object:GetMass();
    local gravity = workspace.Gravity;
	set_Powers(mass, gravity)
end

So, we are done. Let’s now test it!

https://streamable.com/6lye4b

Floating

https://streamable.com/tmh1q7

Not falling downwards (proved in video that the object is unanchored)

Thank you for viewing this tutorial! If you find any mistakes [grammar mistakes i.e information mistakes], comment it, so I’ll correct them. :pray:

What do you think of the tutorial?
  • Great!
  • Good.
  • Okay.
  • Could’ve been better.

0 voters

16 Likes

Hey. For some reasons videos don’t view, just click on the links.

1 Like

Couldn’t you just anchor the part? I don’t understand any use cases for using this over anchoring a part. Correct me if I’m wrong.

Yes, but in the video I showed the part was not anchored.

What I’m saying is what use case is there for using your method instead of just clicking the properties box to anchor it?

I just used that to show a proof that gravity does not impact the object.
Thank you for the comment though :pray:

1 Like

I still don’t think you understand. @Notrealac0unt is trying to say, basically, why would you do all of these steps instead of anchoring the part you don’t want affected.

2 Likes

I can see what OP is trying to do I guess.

I think he wants to make it so that objects are not affected by gravity but are affected by other forces
So players could push the part around without it falling to the ground.

If you just anchor it part, nothing can push the part around.

12 Likes

Anchoring a part is much easier?

This is cool, but why not just turn on Massless in the properties tab?

Okay… this is… very poorly optimized.
Let’s assume you have eighteen parts doing this. It’s eighteen for loops, for a variable that will never change. Remove the function, and remove the loop. Will do the job.

A BodyForce’s Force property stays the same after being set as far as I know.
Also, I think you can do it easier than that. Set its MaxForce property to 0, 99999999, 0, and its P property to 9999999. It’ll just float. No need for a script.

Thanks for the tutorial anyways!

3 Likes

Massless makes the property not have a mass, but still have gravity applying.

Massless objects are still affected by gravity.

The purpose of it is not parts that is not to simulate anchoring, rather making an object unaffected by gravity. I showed an example that this does not fall only to prove that it is unaffected by gravity, if gravity had an affect on it, it’d have fallen downwards.

Again, this is not it’s purpose. It’s purpose is to make an object unaffected by gravity, I just used that as a proof that it is unaffected by gravity.

Hey. I just figured out that the variables don’t change, so I updated it.
Both ways are necessary with a script i.e without, this is more of an educational tutorial of no more than 9th grade physics.
Thank you for the comment. :pray:

Hey! Thanks for taking into account my comment.
I’ve tested the one with BodyVelocity. It doesn’t require a script. I can guarantee it.

Where BodyForce takes into account many parameters, BodyVelocity just sets the velocity.
Try it on Studio: you’ll see it works, without a script.

Note: If you mean creating a BodyVelocity through Instance.new, don’t mind that comment.

1 Like

Thank you for this. I had a issue for a long time where in VR the players body parts would move downwards due to gravity and this has solved my problem! Thank you so so much!

2 Likes