constraint.Weld does not work in most cases !

Hello all,

So again, I’m still on trying to attach a prop the the player’s hand, however I can’t arrive to weld it !

The function constraint.Weld does not work in most cases. It works only on ragdolls. When I try to weld a prop to the player it’s always returning false. But when I try to weld a ragdoll to the player it works…

Here is my code :



//The hand var is the name of the hand to attach object to
	local leftHandPos = ply:GetBonePosition(ply:LookupBone("ValveBiped.Bip01_L_Hand"))
	local rightHandPos = ply:GetBonePosition(ply:LookupBone("ValveBiped.Bip01_R_Hand"))
	
	if (hand == "left") then		
		self:SetPos(leftHandPos)
		
		local bool = constraint.Weld(ply, self, 7, 0, 0, true, false)
		GameGlobal:PrintMessage("ConstraintWeldAdder : " .. tostring(bool))
		ply.HasCase = bool
	elseif (hand == "right") then
		self:SetPos(rightHandPos)
		
		local bool = constraint.Weld(ply, self, 11, 0, 0, true, false)
		GameGlobal:PrintMessage("ConstraintWeldAdder : " .. tostring(bool))		
		ply.HasCase = bool
	end


Constraints are SERVERside. For this you’ll want to use either BoneMerge / SetParent / Update position of object each frame after drawing the player ( not as expensive as it sounds ) - You can use PostPlayerDraw, a clientside hook.

Yes but if it’s client side, other players will not see the attachement.

Sorry, but I think it’s impossible… I made some tests and theres no ways to attach a prop to a ragdoll’s bone without changing the base C++ code of the Engine or creating a player model for each suitcase props…

SetParent crashes completely the player, it makes it unmovable and when you unparent the entity it simply creates a Crazy Physics Removing. Weld always tell that it can’t weld.

About BoneMerge I don’t know this function…

[editline]18th March 2015[/editline]

The BoneMerge does not existing…

I’ll close this thread due to the fact it seams to be impossible without changing Engine code…

Little update :

Found a way.

Entity:FollowBone and Entity:SetLocalPos + Entity:SetLocalAngles… However you need to know the offset of the suitcase model.