I am not too bad at lua, but I am just learning 3d2d
[LUA]
hook.Add( "HUDPaint", "Draw3dTest", function()
for _,ent in ipairs( ents.GetAll() ) do
if( ent:IsValid() ) then
if( ent:GetClass() == "prop_physics" ) then
cam.Start3D2D( ent:GetPos + Vector( 0,0, 20 ), EyeAngles(), 10 )
draw.SimpleText(
"Test",
"ScoreboardText",
0,
0,
color_white,
TEXT_ALIGN_CENTER,
TEXT_ALIGN_CENTER,
1,
color_white
)
cam.End3D2D()
end
end
end
end )
[/LUA]
When This is ran, there are no console errors. If you cannot tell, im trying to get it to say "Test" above all props.
HUDPaint is a 2D drawing hook, so don't use it for 3D stuff. Use one of the following hooks:
[b][url=wiki.garrysmod.com/?title=Gamemode.PostDrawOpaqueRenderables]Gamemode.PostDrawOpaqueRenderables[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b][url=wiki.garrysmod.com/?title=Gamemode.PostDrawTranslucentRenderables]Gamemode.PostDrawTranslucentRenderables[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Also, you can shorten your loop code by using [b][url=http://wiki.garrysmod.com/?title=Ents.FindByClass]Ents.FindByClass[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] instead of ents.GetAll() and your if.
Thanks overv
Sorry, you need to Log In to post a reply to this thread.