Door knock animation

I was wondering about a door knock animation I know that in Half Life 2 I saw in half life 2 someone knocks on the door and I was wondering if gmod got that kind of animation

Playermodels won’t have it, but NPC models will.

Thanks and also how do I make that animation to work on the player?

Yea i’m asking if theres any way to either create or convert the animation to playermodels…

And that is a modeling question, not a Lua question. Post in the appropriate forum.

No it’s a lua question. You can apply NPC animations to players, it is possible.

That’s what I thought, it seems that I was right…

Would love to know the name of that animation

Use Source SDK model viewer and find the name of the sequence.

Thanks I tried using SetSequence knowing that it probably wont work on a playermodel and it really didn’t

Any suggestions?

You’re going to have to get hacky.


local m = FindMetaTable( "Player" )

local function MakeProxy( pl, mdl )
	local e = ClientsideModel( mdl, RENDERGROUP_OPAQUE )
		e:SetPos( pl:GetPos( ) )
		e:SetAngles( pl:GetAngles( ) )
	e:Spawn( )
	
	pl:SetParent( e )
	pl:AddEffects( EF_BONEMERGE )
	
	return e
end

local function ApplySettings( proxy, pbr, params )
	proxy:SetPlaybackRate( pbr or 1 )
	
	local k, v
	
	for k, v in pairs( params or { } )
		proxy:SetPoseParameter( k, v )
	end
end

local function FinishProxy( pl, proxy )
	pl:SetParent( NULL )
	SafeRemoveEntity( proxy )
end

function m:PlaySequenceProxy( model, sequence, pbr, params )
	local e = MakeProxy( self, model )
	ApplySettings( e, pbr, params )
	
	e:ResetSequence( sequence )
	
	timer.Simple( e:SequenceDuration( ), function( ) FinishProxy( self, e ) end )
end

function m:PlayActivityProxy( model, activity, pbr, params )
	local e = MakeProxy( self, model )
	ApplySettings( e, pbr, params )
	
	e:ResetSequence( e:SelectWeightedSequence( activity ) )
	
	timer.Simple( e:SequenceDuration( ), function( ) FinishProxy( self, e ) end )
end

And then you’d do something like:


pl:PlaySequenceProxy( "models/alyx.mdl", "Fear_Reaction", .25 )

This code isn’t tested or set to work. It is just to show you the way I would try going about it. It would require the model you want to proxy the animation from to have a skeleton compatible with the player model, which really means anything with the ValveBiped skeleton for the most part.

Thanks but it doesn’t seem to do the animation i’ve used a normal NPC suppose to work