Entities randomly not rendering.

Over the past month i’ve been working on a dodgeball gamemode.

However, throughout development, I’ve had a particular issue that’s been difficult to squash.

Some of my scripted entities are refusing to render, and its completely random.

Witness it for yourself.

Within the video, the red outlines are supposed to be crates, and a bunch of dodgeballs aren’t rendering.

Here is the clientside code for the entities that are refusing to render.
First we have cl_halo.lua, this file is initialized clientside with the gamemode.



hook.Add( "PreDrawHalos", "AddHalos", function()
	halo.Add( ents.FindByClass( "sent_powerup" ), Color( 255, 0, 0 ), 5, 5, 2 ) // this will highlight the powerups in a red halo, not through walls.
	//halo.Add( ents.FindByClass( "dodge_hole" ), Color( 0, 0, 255 ), 5, 5, 2 )
end )


One of the powerup files, this is then cl_init for the explosive dodgeball, this doesn’t render always.



include('shared.lua')

function ENT:Initialize()
end

function ENT:Think()
end

function ENT:Draw()

	self.Entity:DrawModel()
end



This is the cl_init for the black hole dodgeball




include('shared.lua')

function ENT:Initialize()
end

function ENT:Think()

end
ENT.Sprite = Material( "effects/blueflare1" )
function ENT:Draw()


        render.SetMaterial( self.Sprite )
        render.DrawSprite( self:GetPos(), 25, 25, Color( 25, 255, 255, 255 ) )

        		local dlight = DynamicLight( self:EntIndex() )
	if ( dlight ) then
		local r, g, b, a = self:GetColor()
		dlight.Pos = self:GetPos()
		dlight.r = 25
		dlight.g = 255
		dlight.b = 255
		dlight.Brightness = 1
		dlight.Size = 2048
		dlight.Decay = 2560
		dlight.DieTime = CurTime() + 1
        dlight.Style = 1
	end
	cam.Start2D()
	local spos = self:GetPos():ToScreen()

	local dist_mult = - math.Clamp(self:GetPos():Distance(LocalPlayer():Ge  tPos()) / 1000, 0, 1) + 1
	//	print()
		DrawSunbeams(
			0,
			0.1,
			0.5,
			spos.x / ScrW(),
			spos.y / ScrH()
		)
	cam.End2D()

	self.Entity:DrawModel()
	
end






Finally, this is the last scripted entity of which is refusing to render and the one of which i am having the most trouble with.




include('shared.lua')

function ENT:Initialize()
	self.Entity:SetModel( "models/props_junk/wood_crate001a.mdl" )
end

function ENT:Think()

end
ENT.Sprite = Material( "effects/blueflare1" )
function ENT:Draw()
 self:DrawModel()


 	local typ = self:GetNWString("TYPE")
 	local tab = GAMEMODE.PowerUps[typ]
 	local tabexist = false
 	local tex = Material("materials/dodgeball/items/default.png")
 	if tab then 
 		tabexist = true 
 	end
 	if tabexist==true then 
 		local ic = tab.icon 
 		if ic then 
 		
 			tex = Material(tab.icon)

 		end 
 	end
 	



		surface.SetDrawColor(Color(255,255,255,math.sin(Cu  rTime()^1.3)*100 + 155))
		surface.SetMaterial(tex)

		 cam.Start3D2D( self:LocalToWorld(Vector(20.2,-15,15)), self:LocalToWorldAngles( Angle(0,90,90) )  , 1 )
				surface.DrawTexturedRect(0 ,0, 31, 31 )
		 cam.End3D2D()
		 cam.Start3D2D( self:LocalToWorld(Vector(-15,-20.2,15)), self:LocalToWorldAngles( Angle(0,0,90) )  , 1 )
				surface.DrawTexturedRect(0 ,0, 31, 31 )
		 cam.End3D2D()
		 cam.Start3D2D( self:LocalToWorld(Vector(15,20.21,15)), self:LocalToWorldAngles( Angle(0,180,90) )  , 1 )
				surface.DrawTexturedRect(0 ,0, 31, 31 )
		 cam.End3D2D()
		 cam.Start3D2D( self:LocalToWorld(Vector(-20.2,15,15)), self:LocalToWorldAngles( Angle(0,-90,90) )  , 1 )
				surface.DrawTexturedRect(0 ,0, 31, 31 )
		 cam.End3D2D()
 

end







Any help would be dearly appreciated.

Probably problematic transmit state, or bad renderboounds.

Thanks, I’ll attempt to force TRANSMIT_ALWAYS, though i’m not using any modified renderbounds…

A quick question as well: Could the client’s view entity being bad cause such an issue?

For example:


function ThirdPerson.Enable(player)

	local entity = ents.Create("base_anim")
	entity:SetModel("models/props_c17/oildrum001.mdl")
	entity:Spawn()
	entity:SetHealth(99999)
	entity:SetAngles(player:GetAngles())
	entity:SetMoveType(MOVETYPE_NONE)
	entity:SetParent(player)
	entity:SetPos(player:GetPos() + Vector(0, 0, 60))
	entity:SetColor(Color(0,0,0,0))
	entity:SetRenderMode(RENDERMODE_NONE)
	entity:SetSolid(SOLID_NONE)
	player:SetViewEntity(entity)
	player:SetNetworkedInt("thirdperson", 1)
end