garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

Physgun resets SENTs buoyancy

Open AdventureBootCoder opened this issue 1 year ago • 3 comments

This has been happening for a while now, on several different branches. If you spawn an entity with it's buoyancy set via code and then handle it with the physgun, the buoyancy is reset:

self:GetPhysicsObject():SetBuoyancyRatio(.8)

However this is fixed by using a workaround hook:

hook.Add("PhysgunDrop", "SetBouyancyOnDrop", function(ply, ent)
	if ent:GetClass() == "classname" then
		local phys = ent:GetPhysicsObject()
		timer.Simple(0, function()
			if IsValid(phys) then
				phys:SetBuoyancyRatio(.8)
			end
		end)
	end
end)

I feel like it's not intended to do this so I thought I'd report it.

AdventureBootCoder avatar Jan 18 '24 17:01 AdventureBootCoder

P.S. It also seems to be happening with the grav gun as well

AdventureBootCoder avatar Jan 18 '24 17:01 AdventureBootCoder

This is an unfortunate reality of what PhysObj:SetMass does. Since we can't even retrieve the buoyancy ratio from the physics engine, this cannot be fixed properly.

robotboy655 avatar Jan 19 '24 17:01 robotboy655

Ah okie, thanks for the reply, I'll just have to use my workaround hook for all of my ents that require being buoyant

AdventureBootCoder avatar Jan 19 '24 20:01 AdventureBootCoder