Ignoring un reasonable position

I didn’t found anything up-to-date about this problem, so I’m here now.

Console Log:

I don’t even know what causes this, because before this ‘error’ nothing special happens.

EDIT: Sometimes it’s CBaseEntity::SetAbsOrigin( -nan -nan -nan )

It looks like something just fell out of the world?

Nah, I’ve tested this. Entity just removes, 'coz of crazy physics.

Then maybe an addon is setting an entity’s pos based on CurTime/RealTime?

This is definitely caused by crazy physics.

Is it fixable? :v:

EDIT: I think prop_ragdoll may cause this error, but how should I fix this?

Make sure it’s collision group isn’t set to DEBRIS_TRIGGER


	local pos, angles, model = victim:GetPos(), victim:GetAngles(), victim:GetModel()
	local weps = victim:GetWeapons()
	local rag = ents.Create("prop_ragdoll")
	rag:SetPos(pos)
	rag:SetAngles(angles)
	rag:SetModel(model)
	rag.Player = victim
	rag.IsBody = true
	local bool = true
	local restr = {DMG_CRUSH, DMG_BURN, DMG_FALL, DMG_BLAST, DMG_DROWN, DMG_RADIATION}
	if table.HasValue(restr, dmginfo:GetDamageType()) then bool = false end
	rag:SetNWBool("Alive", bool)
	rag.Model = model
	rag.Weapons = {}
	for _, wep in pairs(weps) do
		if IsValid(wep) then
			table.insert(rag.Weapons, wep:GetClass())
		end
	end
	rag:Spawn()	
	rag:SetCollisionGroup(COLLISION_GROUP_WORLD)

Can you try calling

Entity:CollisionRulesChanged after you set the collision group?

Still crashes with the same error.

[editline]27th July 2015[/editline]

Now I’m 100% sure that ragdolls causes this.

So here’s full code:


local meta = FindMetaTable("Player")
hook.Add("DoPlayerDeath", "GB_Corpses", function(victim, _, dmginfo)
    local pos, angles, model = victim:GetPos(), victim:GetAngles(), victim:GetModel()
    local weps = victim:GetWeapons()
    local rag = ents.Create("prop_ragdoll")
    rag:SetPos(pos)
    rag:SetAngles(angles)
    rag:SetModel(model)
    rag.Player = victim
    rag.IsBody = true
    local bool = true
    local restr = {DMG_CRUSH, DMG_BURN, DMG_FALL, DMG_BLAST, DMG_DROWN, DMG_RADIATION}
    if table.HasValue(restr, dmginfo:GetDamageType()) then bool = false end
    rag:SetNWBool("Alive", bool)
    rag.Model = model
    rag.Weapons = {}
    for _, wep in pairs(weps) do
        if IsValid(wep) then
            table.insert(rag.Weapons, wep:GetClass())
        end
    end
    rag:Spawn()    
    rag:SetCollisionGroup(COLLISION_GROUP_WORLD)
    rag:CollisionRulesChanged()
    local hookname = "CorpseRemove_"..rag:EntIndex()
    hook.Add("Think", hookname, function()
        local pl = rag.Player
        if not rag or not IsValid(rag) then
            hook.Remove("Think", hookname)
        elseif not pl or not IsValid(pl) then 
            hook.Remove("Think", hookname)
            rag:Remove(); 
            return 
        elseif pl:Alive() then
            hook.Remove("Think", hookname)
            rag:Remove(); 
            return 
        end
    end)

    local rag_hold = ents.Create("prop_physics")
    rag_hold:SetModel("models/hunter/blocks/cube025x025x025.mdl")
    rag_hold:SetPos(rag:GetPos())
    rag_hold:SetAngles(rag:GetAngles())
    rag_hold:Spawn()
    rag_hold:SetCollisionGroup(COLLISION_GROUP_WORLD)
    rag_hold:CollisionRulesChanged()
    rag_hold:SetNoDraw(true)
    constraint.Weld(rag_hold, rag, 0, 0, 0, true, true)
    
    timer.Simple(0.1, function()
        if not IsValid(victim) then return end
        net.Start("CorpsePlayerDeath")
        net.WriteFloat(rag:EntIndex())
        net.WriteFloat(CurTime()+GB64.unconsciousTime)
        net.Send(victim)
    end)
    timer.Simple(0.3, function()
        if not IsValid(victim) then return end
        victim.NextSpawnTime = CurTime() + GB64.unconsciousTime
    end)
end)

function meta:CreateRagdoll()
    return NULL
end

bump.

Maybe I can somehow detect “un reasonable position” on entity and remove it?