How to draw sprites that don't show thru walls

I’m trying to draw icons over top of character’s heads, but they can be seen through walls. The fretta player circles use the same methods I do but you can’t see those through walls, so I’m doing something different. Help :I


	cam.Start3D(EyePos(), EyeAngles())
				local pos = (v:GetShootPos() + Vector(0, 0, 20))
				render.DrawSprite(pos, 16, 16, white) --first attempt
				render.DrawQuadEasy(pos, Vector(0,0,1), 16, 16, white )  --otherattempt


Does the material have the $ignorez parameter or whatever?

I have no idea what that even means so probably not

Do you have access to the icon’s .vmt file? If so, post it.

Nope, I was testing it with random HL2 things. Would this be fixed by editing a vmt?

It could be. If the material doesn’t ignore z-order, it might be the camera function to blame. The material is easier to fix, though.

	"$basetexture" 	"texturepath"
	"$vertexalpha"	"1"
	"$vertexcolor"	"1"
	"$nolod" 	"1"

That might be all you need based on the texture.

Are you looking for drawing an icon that grows and shrinks based on distance, or just a generic icon above a player’s head? If you want an icon that’s always facing you, use Vector:ToScreen to convert the vector above the player’s head and use surface.DrawTexturedRect to draw the icon. Otherwise, I’m almost positive the sprite you’re using has ignorez set like Kogitsune said. Definately look into that :smile:

That would be the better method, I would have done it the lazy way, and just do a Trace to determine visibility.


What about the $ignorez method? :expressionless:

Yeah I was actually just looking at your chimerahunt code for the sweat sprite, but the only issue with that is you can either see it or not see it at all. You can see it through walls if part of it is visible in the trace.


One that changes size is what I want to do

I haven’t really touched GMOD since before those functions were even documented, it’s been a while to say the least.

Don’t call it in HUDPaint, call it in RenderScreenspaceEffects()