Get Material of Player Eye Trace

Hi all,

I’m debugging something and need a console command/way of seeing what the entity in my eyetrace material is. I made up this:

lua_run_cl print( LocalPlayer():GetEyeTrace().Entity:GetMaterial() )

But it returns nothing.
How would I get the material of what I’m looking at?


Have you tried HitTexture?

for the trace.HitPos use this: [lua]util.PointContents( trace.HitPos )[/lua]

That’ll give you contents of everything there.

To test for a certain material:

[lua]if ( util.PointContents( _pos3 ), CONTENTS_WATER ) == CONTENTS_WATER ) then[/lua]

keep in mind that material for trace won’t always be reliable. It won’t work on displacements, etc.

Sometimes it doesn’t work at all. On some maps it’ll return the same texture for every brush on the map.