• Getting the material of the worldspawn a trace hit?
    4 replies, posted
I want to see if a traceline is hitting a glass material, either defined by a vmt keyvalue that has the word glass in it, or if the file path has the word glass in it. I know there's a bunch of string functions, however, I can't find out how to get the material of a traceline. There's [b][url=http://wiki.garrysmod.com/?title=PhysObj.GetMaterial]PhysObj.GetMaterial [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] but this won't work. There's also [b][url=http://wiki.garrysmod.com/?title=Entity.GetMaterial]Entity.GetMaterial [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] but this only works on overriden materials. There's a console command "mat_crosshair" which does what I need, but I don't know how to get the value a console command returns. This is for a SWEP by the way.
TraceRes.HitTexture?
Sigh, why didn't I find that. Works now using: if( string.match(tr.HitTexture, "glass") ) then return end I know this only checks texture path, but that should be good enough. Unless there's a quick way to get the keyvalues of the material that it hits, now that I've gotten the material?
I just went through this problem for a custom gib addon i'm working on. here is the thread I had [url]http://www.facepunch.com/threads/1030990-Need-a-function-or-help-in-creating-a-function[/url] it requires a custom dll, but after that it's not too bad. EDIT: Well i guess I was posting about the same time as you, I needed to do it without a trace, so that's the difference between the methods.
Not worth it then. It's really only a polish thing in my gamemode anyways, most of the times tracing against the glass won't help you a bit... I'm can also use a func_no_trace entity and just put that everywhere I don't want the trace going. Thanks though!
Sorry, you need to Log In to post a reply to this thread.