Hi all, I’m having trouble spawning an entity I recently made. For my addon I need to spawn the entity using a tool. However, when I spawn it via ents.Create I can walk straight through it and I can’t pick it up with the physgun or gravity gun, and bullets pass through it too. It does however respond to gravgun punting and collisions with other entities.
I’ve created a smaller test-entity which only has the necessary parts to re-create the problem (acf_spawntest.lua):
AddCSLuaFile() DEFINE_BASECLASS( "base_wire_entity" ) ENT.Type = "anim" ENT.Base = "base_wire_entity" if SERVER then function MakeACF_SpawnTester(Owner, Pos, Angle, Id) local ent = ents.Create("acf_spawntest") if not ent:IsValid() then return false end ent:SetAngles(Angle) ent:SetPos(Pos) ent:Spawn() ent:SetPlayer(Owner) ent:SetOwner(Owner) ent.Owner = Owner ent:SetModelEasy("models/props_c17/light_decklight01_off.mdl") print("spawned") return ent end function ENT:SetModelEasy(mdl) self:SetModel( mdl ) self.Model = mdl self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) local phys = self:GetPhysicsObject() if (phys:IsValid()) then phys:SetMass(1000) end end end
You can use the following line in the console to invoke the ‘MakeACF_SpawnTester’ function:
lua_run local ply = player.GetAll() MakeACF_SpawnTester(ply, ply:GetPos() + Vector(0,0,20), Angle(0,0,0))
I need to be able to spawn the entity without problems via MakeACF_SpawnTester because it’s registered as a duplicator factory for the full entity.
Here’s a video displaying the symptoms:
What’s going wrong? Has anyone seen this before? Can anyone help?! Much thanks up front!