How to make a part anti-gravity

Currently this equation I use works fine for making parts antigravity:

local antigrav = Vector3.new(0, centerpart:GetMass(), 0) * (workspace.Gravity) 
-- this is used for a vectorforce appied to the part

Problem is I need a massless part to be anti-gravity. The part must be massless because I want the part to be able to fly upwards at high forces without the player budging at all.

Not sure why the equation doesn’t work for massless parts. I’ve tried tweaking the equation to no avail.

Idk about any equation but if i need something to be anti-gravity, I use body position. I make the part massless then use a body position and then set the power and Damping as much as the part dont move and dont go towards the position that you set in Body position.

1 Like

I think I’d rather use the equation for gravity since it’s more consistent across parts of differing masses. Also, AlignPosition is the new BodyPosition since the latter has been deprecated

1 Like

You can’t even make a single part massless, because it will be the root of its own assembly, so Part.Massless will be ignored. If you want it to accelerate very quickly, just use CustomPhysicalProperties to give it a super low density.

The part is actually part of a larger assembly of two welded “massless” parts. The CustomPhysicalProperties density is already at the lowest but having a part of roughly (2.5, 2.5, 2.5) size with the lowest density still yields a mass of 0.025, which is too much.

Unfortunately the documentation says about Massless:

If this property is enabled, the BasePart will not contribute to the total mass or inertia of its assembly as long as it is welded to another part that has mass.

Source

I guess this is why it isn’t working, I need both parts to be massless but for some reason Roblox doesn’t allow this?

Try these:

  1. Disable massless and set the part density to the bare minimum in CustomPhysicalProperties (density = 0.01).

  2. Roblox recently released a new feature allowing you modify a part’s density to be lower than air. You can cancel out gravity with air buoyancy (ie the same principle as helium in floating balloons). You can use Archimedes principle to figure out the correct density to cancel out gravity.

Wow, that’s awesome! I didn’t know about this update until you told me. I’ve messed around with it but haven’t been able to work it out yet. I can get my balloon to float but with the 0.0001 density the player gets flung into oblivion when they step on it. I’ll do some more work Friday and see if I can work it out or if I need assitance

Correct. For every assembly, which can be a single part or 2 or more rigidly-welded parts, one of the parts will be the assembly root part, and will have mass, even if all of the parts are set to Massless. An assembly cannot have zero mass, because this can’t be physically simulated. Any non-zero force on a zero-mass entity results in a divide by zero when computing acceleration.

Realistically, a minimum size part with minimum density is already going to have such a low mass that any large force you put on it is going to yeet it so far in one frame that there’s really no point in physically simulating it at all. No one will see the part “fly upwards” if it’s going 100k studs per frame, it will simply disappear. The Roblox physics engine doesn’t use continuous collision, so it won’t even collide with anything either, it will be a virtual neutrino.

1 Like

Sorry just seeing this now. Yeah, and it’s a silly thing to ask for in the first place since in real life a macroscopic object can’t be massless. I suppose what I was expecting was that if an assembly in Roblox became completely massless Roblox would have an internal method for accessing the AssemblyRootPart’s real mass and would counter it with an upwards force thus making the part “weightless” in practice. So strangely I ended up mixing massless with weightless in my head—

1 Like