I'm making a HUD for my gamemode and I want it to slightly move on the screen when the player moves. Like the HUD in Halo moves when you run. Here is my current code:
[CODE]
hook.Add( "PostDrawHUD", "3d2d", function()
--Local Variables--
local ply = LocalPLayer()
local health = ply:Health()
local pos = EyePos() + EyeAngles():Forward() * 10 + EyeAngles():Right() * -6 + EyeAngles():Up() * -4
local ang = EyeAngles()
local hud = { "CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo" }
--Rotation--
ang:RotateAroundAxis(EyeAngles():Up(), -90)
ang:RotateAroundAxis(EyeAngles():Right(), 70)
ang:RotateAroundAxis(EyeAngles():Up(), 10)
--3D2D Start--
cam.Start3D()
cam.Start3D2D( pos, ang, 0.20 )
draw.RoundedBox( 0, -50, -50, 400, 50, Color( 25, 25, 25, 155 ) )
draw.DrawText( "HP ", "DermaDefault", -50, -50, Color( 255, 255, 255 ) )
draw.RoundedBox( 0, 30, ScrH() - 70, 300 * ( math.Clamp( ply:Health(), 0, 100 ) ), 30, Color( 255, 0, 0 ) ) --Health Bar
cam.End3D2D()
cam.End3D()
end)
hook.Add( HUDShouldDraw, DHudHide, function( name )
if table.HasValue( hud, name ) then return false end
end)
[/CODE]Currently I have no code implemented to do the above but I'm pretty sure this [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Lerp]Lerp[/url] would aid in that process.
Sorry, you need to Log In to post a reply to this thread.