I am almost finishing my HUD the only thing I need is help with the model that people normaly add to HUD that you can set to appear the whole body or just the face and stuff. I was trying to find a tutorial for it but I couldn't find a new one or one that works. If anyone can send me a link of how to do it or send me a code and what is what would really help me too.
I think you have to use a [URL="https://wiki.garrysmod.com/page/Category:DModelPanel"]DModelPanel[/URL] for that, and [URL="https://wiki.garrysmod.com/page/Panel/SetVisible"]hide and show[/URL] the panel when the HUD is meant to be shown and hid respectively
Whatever you do though, [B]DON'T[/B] create that panel in a [URL="https://wiki.garrysmod.com/page/GM/HUDPaint"]HUDPaint hook[/URL], because that will make a new panel every frame which causes tons of lag (since the panel doesn't get removed once the frame ends), so create it outside the hook, if you have one.
[editline]12th February 2016[/editline]
I might make an example for you later if I have time
[CODE]
hook.Add( "InitPostEntity", "uniquename", function()
local PlayerModel = vgui.Create( "DModelPanel" )
PlayerModel:SetPos( 200, 200 )
PlayerModel:SetSize( 75, 85 )
PlayerModel:SetModel( LocalPlayer():GetModel() )
PlayerModel.Think = function()
PlayerModel :SetModel( LocalPlayer():GetModel() )
end
PlayerModel.LayoutEntity = function()
return false
end
PlayerModel.Entity:SetEyeTarget( Vector( 100, 100, 100 ) )
PlayerModel:SetFOV( 75 )
PlayerModel:SetCamPos( Vector( 45, 20, 64 ) )
end )
[/CODE]
Change the size, position, and all that shit to your preference.
[QUOTE=Tupac;49729738][CODE]
hook.Add( "InitPostEntity", "uniquename", function()
local PlayerModel = vgui.Create( "DModelPanel" )
PlayerModel:SetPos( 200, 200 )
PlayerModel:SetSize( 75, 85 )
PlayerModel:SetModel( LocalPlayer():GetModel() )
PlayerModel.Think = function()
PlayerModel :SetModel( LocalPlayer():GetModel() )
end
PlayerModel.LayoutEntity = function()
return false
end
PlayerModel.Entity:SetEyeTarget( Vector( 100, 100, 100 ) )
PlayerModel:SetFOV( 75 )
PlayerModel:SetCamPos( Vector( 45, 20, 64 ) )
end )
[/CODE]
Change the size, position, and all that shit to your preference.[/QUOTE]
I copied exactly that and it didnt work in [CODE] PlayerModel:Setpos( 200, 200 ) [/CODE]
I just changed to [CODE] PlayerModel:SetPos( HUD.PosX, HUD.PosY ) [/CODE]
Are there any errors? And you need to rejoin after making changes in order for them to take affect.
[CODE]BGPanel = vgui.Create( "DPanel" )
BGPanel:SetPos( 20, 20 )
BGPanel:SetSize( 200, 200 )
BGPanel:SetBackgroundColor( Color( 0, 0, 0, 255 ) )
local mdl = vgui.Create( "DModelPanel", BGPanel )
mdl:SetSize( BGPanel:GetSize() )
mdl:SetModel( "models/player/gman_high.mdl" )
function mdl:LayoutEntity( ent )
ent:SetSequence( ent:LookupSequence( "menu_gman" ) )
mdl:RunAnimation()
return
end
local eyepos = mdl.Entity:GetBonePosition( mdl.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )
eyepos:Add( Vector( 0, 0, 2 ) ) -- Move up slightly
mdl:SetLookAt( eyepos )
mdl:SetCamPos( eyepos-Vector( -12, 0, 0 ) ) -- Move cam in front of eyes
mdl.Entity:SetEyeTarget( eyepos-Vector( -12, 0, 0 ) )[/CODE]
[IMG]https://wiki.garrysmod.com/images/9/93/DModelPanel_SetCamPos_example1.jpg[/IMG]
It kinda explains itself. Tell me if you need further explanations.
Source: [URL="https://wiki.garrysmod.com/page/DModelPanel/SetCamPos"]DModelPanel/SetCamPos[/URL]
[QUOTE=Tupac;49730158]Are there any errors? And you need to rejoin after making changes in order for them to take affect.[/QUOTE]
Oh Ok let me try here, Can you tell me how the SetCamPos Works[CODE] PlayerModel:SetCamPos( Vector( 80, 20, 64 ) ) [/CODE]
[editline]13th February 2016[/editline]
[QUOTE=Deepnox;49730162][CODE]BGPanel = vgui.Create( "DPanel" )
BGPanel:SetPos( 20, 20 )
BGPanel:SetSize( 200, 200 )
BGPanel:SetBackgroundColor( Color( 0, 0, 0, 255 ) )
local mdl = vgui.Create( "DModelPanel", BGPanel )
mdl:SetSize( BGPanel:GetSize() )
mdl:SetModel( "models/player/gman_high.mdl" )
function mdl:LayoutEntity( ent )
ent:SetSequence( ent:LookupSequence( "menu_gman" ) )
mdl:RunAnimation()
return
end
local eyepos = mdl.Entity:GetBonePosition( mdl.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) )
eyepos:Add( Vector( 0, 0, 2 ) ) -- Move up slightly
mdl:SetLookAt( eyepos )
mdl:SetCamPos( eyepos-Vector( -12, 0, 0 ) ) -- Move cam in front of eyes
mdl.Entity:SetEyeTarget( eyepos-Vector( -12, 0, 0 ) )[/CODE]
[IMG]https://wiki.garrysmod.com/images/9/93/DModelPanel_SetCamPos_example1.jpg[/IMG]
It kinda explains itself. Tell me if you need further explanations.
Source: [URL="https://wiki.garrysmod.com/page/DModelPanel/SetCamPos"]DModelPanel/SetCamPos[/URL][/QUOTE]
I need one that updates when people change their jobs
[editline]13th February 2016[/editline]
[QUOTE=Tupac;49730158]Are there any errors? And you need to rejoin after making changes in order for them to take affect.[/QUOTE]
Are you sure the hook.add comes before the rest of the whole code? [CODE]
hook.Add( "InitPostEntity", "uniquename", function() -- Thats not the whole code [/CODE]
[editline]13th February 2016[/editline]
Does anyone know a good SetCamPos to show the neck and face ???
Sorry, you need to Log In to post a reply to this thread.