I would like to remove gravity from an area of the map. The map is space based, and is the starting area of my game. Players spawn inside a dome with all weapons available. The dome has a forcefield portal that they can go through to exit the dome and be on the outside ledge. What I am trying to accomplish is to remove gravity from everywhere outside the dome. It’s pretty strange to see weapon projectiles fly off in -x² arcs where there should be no gravity. The attached video illustrates the issue that I’m talking about. The projectiles are glowing white sticks that are 8 studs long.
I know I can set workspace.Gravity to zero, but I would like to have gravity inside the dome. I also know that I can apply a VectorForce to counteract gravity, but that would entail significantly more work, especially with weapon projectiles. So is there any way to exclude gravity from certain areas of the map?
You probably can localy use a touched function for this.
I don’t know how your dome is, but if it is made with only one mesh part, you can duplicate it 2 times.
Make one a bit smaller than the original and the other one a bit larger than the original and put them invisible.
Then with a local script, use a touched function to change the gravity while touching the invisible domes, change the gravity to 0 when touching the larger dome and normal gravity when touching the smaller dome.
You can also change the gravity depending of the CFrame or vector3 position of your character.
Something like, if your character humanoidRootPart position x, y and z are >= of a certain position then it change the gravity.
The issue with touch is that it’s pretty unreliable and there are better alternatives,
Also, he wants it to affect projectiles so changing local gravity won’t work.
You still can add a bool value in your character, true = normal gravity, false = zero gravity, and manualy change the bullet physic inside the gun scripts, using this value.
If a projectile is anchored, body movers won’t affect it.
I would do this, use ZonePlus to create an effective zone boundary,
Using that, you can detect when a player enters or leaves the zone.
When they enter, you can instance a new BodyForce by checking if the object is unanchored, and if it is,
get the mass:
local function getMass(obj)
local counter = 0
for _, v in pairs(obj:GetDescendants()) do
if v:IsA("BasePart") then
counter += v:GetMass()
end
end
return counter
end
And make a bodyForce with it, and apply it to the HRP or primary part of model or part
I have thought about doing something like this with the portal. Using a toggle or something every time the player connects with the portal, but that would be unreliable at best because there is no way to know if the player is entering or leaving the dome.
The dome is two separate pieces. The top part is a large sphere where the bottom half is removed and the top half is hollowed out. The bottom part that sits on the baseplate is a hollowed out cylinder. Both are forcefields with a transparency of 0.75.