Prevent Ragdolls (Dead Npcs) From Colliding With the Player
5 replies, posted
Hi all, just a quick question; is there any way to prevent the ragdolls (of dead npcs) from colliding with the player - like how they behave in Half Life 2? I find it quite frustrating especially playing on small corridor-based maps where there are dead ragdolls and they block the player's path, causing the player to jump over them all the time. I am aware that when you uncheck keep corpses, the player can walk through the ragdolls, but the ragdolls disappear after a while and I don't want them to disappear.
Help would be appreciated.
Update the collision type when they're spawned:
self:SetCollisionGroup( COLLISION_GROUP_DEBRIS_TRIGGER );
Sorry, I'm a bit of a noob when it comes to coding - how would I go about doing this, exactly?
bump
I don't know if this is exactly what you need but this is a script that prevents ragdolls from crashing a server by completely removing them. (For TTT)
[lua]
hook.Add("Think","AMB_CrashCatcher",function()
for k, ent in pairs(ents.FindByClass("prop_ragdoll")) do
if IsValid(ent) then
if ent.player_ragdoll then
local velo = ent:GetVelocity( ):Length()
if velo >= 1500 and velo <= 2999 then
AMB_KillVelocity(ent)
ServerLog("[!CRASHCATCHER!] Caught ragdoll entity moving too fast, disabling motion. \n")
elseif velo >= 3000 then
ent:Remove()
ServerLog("[!CRASHCATCHER!] Caught ragdoll entity moving too fast, removing offending ragdoll entity from world.\n")
local messageToShow = "[CRASH PREVENTION] A ragdoll was removed to prevent server crashing. It was "
if CORPSE.GetFound(ent, true) then
PrintMessage(HUD_PRINTTALK, messageToShow .. "an unID'd body.")
else
PrintMessage(HUD_PRINTTALK, messageToShow .. ent:GetNWString("nick") .. "'s body.")
end
end
end
end
end
end)
function AMB_SetSubPhysMotionEnabled(ent, enable)
if not IsValid(ent) then return end
ent:SetVelocity(vector_origin)
if !(enable) then
ent:SetColor(Color(255,0,255,255))
else
ent:SetColor(Color(255,255,255,255))
end
for i=0, ent:GetPhysicsObjectCount()-1 do
local subphys = ent:GetPhysicsObjectNum(i)
if IsValid(subphys) then
subphys:EnableMotion(enable)
if !(enable) then
subphys:SetVelocity(vector_origin)
subphys:SetMass(subphys:GetMass()*20)
end
if enable then
subphys:SetMass(subphys:GetMass()/20)
subphys:Wake()
end
end
end
ent:SetVelocity(vector_origin)
end
function AMB_KillVelocity(ent)
AMB_SetSubPhysMotionEnabled(ent, false)
timer.Simple(3, function() AMB_SetSubPhysMotionEnabled(ent, true) end)
end
[/lua]
p.s. no idea where this script came from just had it sitting in my gmod folder for ages
When 'Keep Corpses' is turned off, the ragdolls are not collidable and will disappear themselves over time. Is there any way to specify how long the ragdolls will stay before they disappear, when 'Keep corpses' is turned OFF?
Sorry, you need to Log In to post a reply to this thread.