• Model in a layer [HUD]
    12 replies, posted
I want this code, playermodel, appear in a layer. Model code: HudModel = vgui.Create("DModelPanel") function HudModel:LayoutEntity( Entity ) return end HudModel:SetModel( LocalPlayer():GetModel() )  HudModel:SetPos(ScrW() * 0.035, ScrH() * 0.02) HudModel:SetSize(95, 95)  HudModel:SetCamPos(Vector( 16, 0, 65 )) HudModel:SetLookAt(Vector( 0, 0, 65 )) Layer code: surface.DrawTexturedRectRotated( ScrW() * 0.06, ScrH() * 0.085, ScrW() * 0.04, ScrH() * 0.07, 45 ) As you can see the shoulders go outside the surface. How would I do this? Any tips? https://files.facepunch.com/forum/upload/251486/198c4075-ff5b-4b93-93e2-1f8e589c3190/My problem.jpg
You have to use stencils, I think you can adapt code from this thread
I will check it out. I have another issue aswell. The HudModel code really lags for me. Is there a way to fix that problem?
To fix the lag issue, draw the vgui once during the hudpaint, not all the time. EX code: local HudModel hook.Add("HUDPaint", "LagFix", function() // Your hud paint stuff if not IsValid(HUDModel) then HudModel = vgui.Create("DModelPanel") function HudModel:LayoutEntity( Entity ) return end HudModel:SetModel( LocalPlayer():GetModel() )  HudModel:SetPos(ScrW() * 0.035, ScrH() * 0.02) HudModel:SetSize(95, 95)  HudModel:SetCamPos(Vector( 16, 0, 65 )) HudModel:SetLookAt(Vector( 0, 0, 65 )) end end)
I tryed that aswell, but the game still puts the FPS bellow 10fps. Is there something else that I can try? Thank you for your time!
It shouldn't lag you as it's only created once. Post your source code?
It's the code that you sended me.
Sorry if I wasn't clear, can you post the full OP code?
No problem. [Lua]
Try moving all of your hudpaint stuff to one hook, there's no need to call it multiple.timrd
I did that so I it's more organized, but indeed that sounds logic. I will try it!
Looking through your source, IsValid says it works on panel elements but from testing it does not. Try using ValidPanel(HudModel) instead of IsValid(HudModel)
Lag is gone now thank you! I will see what I can do with the stencils
Sorry, you need to Log In to post a reply to this thread.