Removing Nextbot Death Ragdolls?

My Nextbot npc dies.
[lua]function ENT:OnKilled( dmginfo )
self:BecomeRagdoll( dmginfo )
end
[/lua]
Simple, it produces a ragdoll that syncs with the speed an animation the nextbot died in.
I want to remove the ragdoll after 5 seconds.

So I tried-
[lua]function ENT:OnKilled( dmginfo )
local gib = ents.Create( “prop_ragdoll” )
gib:SetModel( “models/mymodel.mdl” )
gib:SetPos( self:GetPos() )
gib:SetAngles( self:GetAngles() )
gib:Spawn()
gib:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
gib:GetPhysicsObject():AddVelocity( Vector( math.Rand( -150, 150 ), math.Rand( -150, 150 ), math.Rand( -150, 50 ) ) )
timer.Simple ( 6, function () gib:Remove () end )
self:Remove()
end
[/lua]
It works fine, but it activates all body-groups and doesn’t sync the velocity or animation - it just drops dead on the spot t-posed to ragdoll no-matter the speed.
So how would I add a remove timer to the first method, or how would I sync the animation/speed with the other method? Either answer is greatly appreciated.

Bump.

38 views and no answer?

You could use this instead of the timer:


SafeRemoveEntityDelayed( gib, 5 );

As for making sure the ragdoll spawns and falls to give the illusion that the player / npc fell over, take a look at terrortown/corpse.lua

function CORPSE.Create(ply, attacker, dmginfo)

Or, more specifically, around line 410 and on: – position the bones

Wow dude, I really appreciate it, this worked. Thanks alot :dance: