Setting BodyVelocity consistently regardless of player mass

Trying to consistently launch players, giving them the same landing zone regardless of mass.

I launched a player who started with about 14 mass, then deleted a few limbs, and launched them again with 9 mass, and they didn’t get even close to where the first one did. I’m obviously doing this math incorrectly, any suggestions?

local canLaunch = true
local character = {}

function character:GetMass()
	local mass = 0
	for _,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
		if ((v:IsA("BasePart") or v:IsA("MeshPart")) and not v.Massless) then
			mass = mass + v:GetMass()
		end
	end
	return mass
end

local launchers = game.Workspace.Launchers:GetChildren()
for iteration, launcher in ipairs(launchers) do
	local launchPart = launcher.LaunchPart
	launchPart.Touched:Connect(function(part)
		if part.Parent == game.Players.LocalPlayer.Character and canLaunch then
			canLaunch = false
			local BodyVelocity = Instance.new("BodyVelocity")
			BodyVelocity.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart
			local characterMass =character:GetMass()
			print(characterMass)
			BodyVelocity.Velocity = launchPart.CFrame.LookVector * (16.85 * characterMass)
			BodyVelocity.MaxForce = Vector3.new(99999999,99999999,99999999)
			wait(.3)
			BodyVelocity:Destroy()
			canLaunch = true
		end
	end)
end

The player seems to consistently launch without my mass adjustments, regardless of player mass.

If I set the velocity to 240, (16.85 * 14) 14, being the players default mass, then remove limbs and hats making the characters mass 9, and launch them again, they land in the same place. Am I doing this correctly?

It seems to me that the mass doesn’t matter when using a BodyVelocity if you want the velocity to be the same amongst all player launches (when using high enough MaxForce, what you have).
When using a BodyForce, however, you do need to adjust the Force when you deal with variable masses if a consistent velocity etc. is the desired result.

The solution to get them to land in the same place: Keep the MaxForce very high and remove the characterMass from the BodyVelocity’s Velocity calculation.

Alright, that’s what I figured, because that’s the results I was getting. Just wanted to make sure I wasn’t going to run into problems when I implement this. Thank you.

Change MaxForce with number * mass ^ 2, that works very nice for me (just writing if someone finds this)

1 Like