So I've managed to almost make a fully functional HUD, my first ever. Complete with lerps and blurs, it looks quite nice, however the DModelPanel which is responsible for rendering the player isn't doing what I tell it to do. when I changed the height of the HUD in the settings, as you can see, it got removed and redrawn, except for the panel. As well as this, despite setting playermodel:Setanimated(false), it still animates no matter what, and when I change job the model isn't removed as it should be and is just drawn on top of the existing one. Additionally, when I run the HUD with this function enabled, my game drops from around 150 to 30fps. Any help would be appreciated.
local campos=Vector(16,4,60)
local lookat=Vector(0,0,60)
local function playerModel()
playermodel = vgui.Create("DModelPanel")
playermodel:SetModel(LocalPlayer():GetModel())
function playermodel:LayoutEntity(Entity) return end
playermodel:SetAnimated(false)
playermodel:SetPos(2*padding,ScrH()-(2*padding)-playerheight)
playermodel:SetSize(playerwidth, playerheight)
playermodel:ParentToHUD()
playermodel.Entity:SetPos(playermodel.Entity:GetPos()-Vector(0,0,4))
playermodel:SetCamPos(campos)
playermodel:SetLookAt(lookat)
timer.Create("update",1,0,function()
if LocalPlayer():GetModel()~=PlayerModel.Entity:GetModel() then
playermodel:Remove()
playermodel = vgui.Create("DModelPanel")
playermodel:SetModel(LocalPlayer():GetModel())
function playermodel:LayoutEntity(Entity) return end
playermodel:SetAnimated(false)
playermodel:SetPos(2*padding,ScrH()-(2*padding)-playerheight)
playermodel:SetSize(playerwidth, playerheight)
playermodel:ParentToHUD()
playermodel.Entity:SetPos(playermodel.Entity:GetPos()-Vector(0,0,4))
playermodel:SetCamPos(campos)
playermodel:SetLookAt(lookat)
end
end)
end
hook.Add("InitPostEntity","playermodel",playermodel)
https://files.facepunch.com/forum/upload/249568/aa42f94d-adfe-453e-8346-17fa364ed092/image.png
Just update the panel, dont recreate it.
timer.Create("update_hud_model",1,0,function()
local ply_model = LocalPlayer():GetModel()
if ply_model ~= playermodel:GetModel() then
playermodel:SetModel(ply_model)
end
end)
Sorry, you need to Log In to post a reply to this thread.