• Find water's surface with trace
    4 replies, posted
How can I find where air changes to water and vise-versa? I tried using a combination of trace masks, but I couldn't find anything that would void out empty space.
That's odd, you should be able to use traces, like a player's eyetrace. [CODE] bit.band( util.PointContents( track.HitPos ), CONTENTS_WATER ) == CONTENTS_WATER[/CODE] where table:[I]track[/I] is a trace result. [Returns true if the hit position's water]
But that doesn't return where the trace changes from water to empty space. That just says if the trace ended in water.
[lua] local trace = { start = LocalPlayer():EyePos(), endpos = LocalPlayer():EyePos() + LocalPlayer():EyeAngles():Forward() * 60000, filter = LocalPlayer(), mask = CONTENTS_WATER } trace = util.TraceLine(trace) [/lua] This seems to work for me, but it doesn't detect the edge if the trace starts in water. You can try doing a reverse trace if it doesn't hit anything. It seems to only hit water, and ignores world entirely.
[QUOTE=typedef state;50767835][lua] local trace = { start = LocalPlayer():EyePos(), endpos = LocalPlayer():EyePos() + LocalPlayer():EyeAngles():Forward() * 60000, filter = LocalPlayer(), mask = CONTENTS_WATER } trace = util.TraceLine(trace) [/lua] This seems to work for me, but it doesn't detect the edge if the trace starts in water. You can try doing a reverse trace if it doesn't hit anything. It seems to only hit water, and ignores world entirely.[/QUOTE] Yeah, I was trying to figure out how to do it from the water. I guess tracing backwards is the best way.
Sorry, you need to Log In to post a reply to this thread.