Entity.AddEffects( EF_BONEMERGE ) not working?

I’m not entirely sure what I’m doing wrong here.

I have two entities - prop_dynamics.

One is barney ( models/barney.mdl )
The other is the hl2 pistol ( models/weapons/w_pistol.mdl )

I’m using this code:



pistol:SetParent( barney )
pistol:AddEffects( EF_BONEMERGE )


On either client or server, the result is the same - it teleports into his crotch like missing bones. I can change it to any weapon model or any hl2 character model that has the correct bones, but it does not appear to be merging with the correct bones. Given the pistol only has two bones ( Bip01_R_Hand and Weapon_Bone ), I’m confused here.

What am I doing wrong? Or does it just not work? Is there anything else I’m supposed to be doing in addition to what I am doing above?

Things I have tried:
Various models mixed ( css weapons and player models, etc )
Various entities ( prop_physics, dynamic, ragdolls )
Different effects ( EF_BONEMERGE_FASTCULL )
Placing the model before adding the effect

None of those work :frowning: for me.

Tried firing the “setparentattachment” input?

This seems to defy the point of using a bone merge to begin with, but I’ll try it shortly.

[editline]Now[/editline]

That appears to have been the problem. Thank you.

Any related input on why the attachment insists on pointing backwards?

If I do this:



local function Test( pl )
	local pistol, barney, pos, att, seq
	
	pos = pl:GetEyeTrace( ).HitPos
	
	pistol = ents.Create( "prop_dynamic" )
	barney = ents.Create( "prop_dynamic" )
	
	pistol:SetModel( "models/barneyhelmet_faceplate.mdl" )
	barney:SetModel( "models/barney.mdl" )
	
	pistol:SetPos( pos )
	barney:SetPos( pos )
	
	barney:Spawn( )
	pistol:Spawn( )
	
	seq = barney:LookupSequence( "helmet_reveal" )
	
	barney:ResetSequence( seq )
	
	att = barney:GetAttachment( barney:LookupAttachment( "faceplate_attachment" ) )
	
	pistol:SetParent( barney )
	
	pistol:SetLocalAngles( att.Ang )
	pistol:SetLocalPos( att.Pos )
	
	pistol:Fire( "SetParentAttachment", "faceplate_attachment", 0 )
	
	pistol:AddEffects( EF_BONEMERGE_FASTCULL )
	
	timer.Simple( 10, barney.Remove, barney )
end

concommand.Add( "/test", Test )


It works and looks correct.

But if I do this: ( without or without the angles code )



local function Test( pl )
	local pistol, barney, pos, att, seq
	
	pos = pl:GetEyeTrace( ).HitPos
	
	pistol = ents.Create( "prop_dynamic" )
	barney = ents.Create( "prop_dynamic" )
	
	pistol:SetModel( "models/weapons/w_pistol.mdl" )
	barney:SetModel( "models/barney.mdl" )
	
	pistol:SetPos( pos )
	barney:SetPos( pos )
	
	barney:Spawn( )
	pistol:Spawn( )
	
	seq = barney:LookupSequence( "helmet_reveal" )
	
	barney:ResetSequence( seq )
	
	att = barney:GetAttachment( barney:LookupAttachment( "anim_attachment_rh" ) )
	
	pistol:SetParent( barney )
	
	pistol:SetLocalAngles( att.Ang )
	pistol:SetLocalPos( att.Pos )
	
	pistol:Fire( "SetParentAttachment", "anim_attachment_rh", 0 )
	
	pistol:AddEffects( EF_BONEMERGE_FASTCULL )
	
	timer.Simple( 10, barney.Remove, barney )
end

concommand.Add( "/test", Test )


The attachment is backwards on his hand??? But when given the actual pistol, something magical happens and he holds it correctly.

Not sure about server-side but it works fine on the clients. I use it to attach a weapon world model to a player model in a modified DModelPanel thingy