Bonemerging thirdperson issues for entities

After merging a entity’s model with an NPC to give it the appearance of the entity’s model, I ran into an issue with the old model. If I’m in thirdperson, the old model appears no matter what. Now, if you’re blending models on players and have this same issue, it can be fixed by calling SetBlend in both GM.PrePlayerDraw and GM.PostPlayerDraw. For entities, however, I’m not sure how to achieve this.


function ENT:Initialize()
	self:SetSolid(SOLID_NONE)
	self:SetMoveType(MOVETYPE_NONE)
	self:AddEffects(EF_BONEMERGE)

	local pPlayer = self:GetOwner()
	if pPlayer:IsValid() then
		self:SetRenderMode(pPlayer:GetRenderMode())
		pPlayer:SetRenderMode(RENDERMODE_NONE)
	end
end

if CLIENT then
	local SetBlend = render.SetBlend
	function ENT:Draw()
		local owner = self:GetOwner()
		if IsValid(owner) and (owner:Health() > 0) then
			local col = owner.OldColor or owner:GetColor()
			self:SetColor(col)

			owner:RemoveAllDecals()
			if owner:GetRenderMode() ~= RENDERMODE_NONE then
				owner:SetRenderMode(RENDERMODE_NONE)
			end

			SetBlend(0.5)
			--if not MySelf:InThirdPerson() then
				self:DrawModel()
			--end
			SetBlend(1)
		end
	end
end

Bump. Am I the only person who’s run into this issue?

The issue is that child entities only draw when the parent does. You need to manually draw the entity, so it would go something like:


function ENT:Initialize( )
  self:AddEffects( EF_BONEMERGE + EF_NODRAW )
  ...

  if CLIENT then
    hook.Add( "PreDrawPlayer", self, self.PreDrawPlayer )
  end
end

function ENT:PreDrawPlayer( pl )
  pl:SetRenderMode( RENDERMODE_NONE )
  self:Draw( )
end

Not tested, but you get the idea.

Yes, I understand the concept of how PreDrawing players works, but I’m talking about doing this on npc_zombie.
Edit: Maybe if you avatar stopped shaking his head for two seconds he could have read it properl- nevermind.

Jumped the gun when I read the post and got to the PreDrawPlayer stuff.

The real issue is still that you need to control the drawing since this is expected engine behavior.

Maybe something more along the lines of


function ENT:PreDrawTranslucentRenderables( )
  self:Draw( )
end

in place of PreDrawPlayer would work.

Might need to SetNoDraw on the parented npc as well when you stick the entity on it.