• Sprite visability help
    3 replies, posted
Hi all, Today I wanted to make some sprites and I found some code on the wiki which works for me: [CODE] local pos, material, white = Vector(-6124.304688, -9824.836914, 203.031250 ), Material( "sprites/glow01" ), Color( 255, 255, 255, 255 ) --Define this sort of stuff outside of loops to make more efficient code. hook.Add( "HUDPaint", "lightstuff", function() cam.Start3D( EyePos(), EyeAngles() ) -- Start the 3D function so we can draw onto the screen. render.SetMaterial( material ) -- Tell render what material we want, in this case the flash from the gravgun render.DrawSprite( pos, 32,32, white ) -- Draw the sprite in the middle of the map, at 16x16 in it's original colour with full alpha. cam.End3D() end ) [/CODE] Now what I wanted to know is how can I make it so if the person is looking where the sprite is but has something blocking their view I can make the sprite hide itself. I know it will be an if statement but I do not know how to calculate if the person can see the sprite directly. So to sum it up. How can I make a sprite hide itself when it is not physically visible. (e.g. Something blocking the player's view) Thanks, Computer600
Anyone got any ideas?
surface.SetMaterial surface.SetDrawColor(white) surface.DrawTexturedRect
[QUOTE=Computer600;46528364]Hi all, Today I wanted to make some sprites and I found some code on the wiki which works for me: [CODE] local pos, material, white = Vector(-6124.304688, -9824.836914, 203.031250 ), Material( "sprites/glow01" ), Color( 255, 255, 255, 255 ) --Define this sort of stuff outside of loops to make more efficient code. hook.Add( "HUDPaint", "lightstuff", function() cam.Start3D( EyePos(), EyeAngles() ) -- Start the 3D function so we can draw onto the screen. render.SetMaterial( material ) -- Tell render what material we want, in this case the flash from the gravgun render.DrawSprite( pos, 32,32, white ) -- Draw the sprite in the middle of the map, at 16x16 in it's original colour with full alpha. cam.End3D() end ) [/CODE] Now what I wanted to know is how can I make it so if the person is looking where the sprite is but has something blocking their view I can make the sprite hide itself. I know it will be an if statement but I do not know how to calculate if the person can see the sprite directly. So to sum it up. How can I make a sprite hide itself when it is not physically visible. (e.g. Something blocking the player's view) Thanks, Computer600[/QUOTE] In HUDPaint, you are within a cam.Start2D with render.IgnoreZ(true) (or so I believe). Call this in the PostDrawOpaqueRenderables hook. You can remove the cam.Start3D()/cam.End3D() then. It's implied.
Sorry, you need to Log In to post a reply to this thread.