So I was working on this player movement script that counteracts gravity so you float midair, the issue is, when you bump into another part, you either go up or down and the effect is ruined.
Sections of my movement script that counteracts gravity:
That idea is not out of the box but are you getting the whole mass of the character or just the rootpart?
I have a function to get the model of the whole mass:
local function GetModelMass(Model)
local Mass = 0
for i, v in ipairs(Model:GetDescendants()) do
if v:IsA("BasePart") then
Mass += v:GetMass()
end
end
return Mass
end
So there are no other parts in the character, but also maybe try making the vectorforce relative to the world and every heartbeat do something like this;
What do you mean this could affect it because relative to world will make it so the Y axis is up and down and not based upon the part’s top and bottom face/cframe.
--assuming the parts are unanchored, grouped and welded
local model = script.Parent
local bodyForce = Instance.new("BodyForce", model.PrimaryPart)
local totalMass = 0
for i,v in pairs(model:GetChildren()) do
if v:IsA("BasePart") then
totalMass += v:GetMass()
end
end
bodyForce.Force = Vector3.new(0, totalMass * game.Workspace.Gravity, 0)
I just tested using the body position and the same issue appeared as the first time I used them. The character floats down and it gives a low gravity affect, and the character’s X and Z axis are both affected.
local position = Instance.new("BodyPosition")
position.MaxForce = Vector3.new(1000000, 1000000, 1000000)
position.D = 1000000
position.P = 1000000
position.Parent = prim
coroutine.wrap(function()
game:GetService("RunService").Heartbeat:Connect(function()
position.Position += Vector3.new(0, prim.Position.Y, 0)
end)
end)()
That is because there should only be a max force on the y axis, and you should also have the equation in it too; You also need to have less dampening “D” then the Power “P” I prefer around 100 to 10 times less.
Hey sorry for the late response, I had to do something out of the blue, but the code did not work, it had that same low gravity feel that I’m not after, but the affect was only present in the Y axis, which is good.