Model Panel?

function CharacterCreation()
	local CharCreate = vgui.Create( "DFrame" )
	CharCreate:SetPos(ScrW()/5.5, ScrH()/4)
	CharCreate:SetSize(650,400)
	CharCreate:SetTitle("Character Creation")
	--Extra Properties
	CharCreate:ShowCloseButton(true)
	CharCreate:SetVisible(true)
	CharCreate:SetDraggable(false)

	CharCreate:MakePopup()
	
	--Model Panel Child
	local ModelView = vgui.Create("DModelPanel")
	ModelView:SetModel("models/player/group01/male_01.mdl")
	ModelView:SetSize(100,400)
	ModelView:SetCamPos( Vector(70,80,60))
	ModelView:SetLookAt( Vector(0,0,0))
	CharCreate:AddItem(ModelView)
end
concommand.Add("LRP_CharCreate", CharacterCreation)

Why does this only show up as the Frame? (I did have the position set once but it didn’t help at all)

EDIT: Error received:

gamemode/cl_init.lua:24: attempt to call method ‘AddItem’ (a nil value)

For some reason, DModelPanels really don’t like to work if they’re not square. Try setting it to 400 x 400.

Okay, Ill Try it.

EDIT:

I still get the same error of:

TestRP/gamemode/cl_init.lua:23: attempt to call method ‘AddItem’ (a nil value)

but now its showing, yet the head on the model is cut off >.<

Oh, duh. That’s because AddItem is only valid for stuff like DComboBox, DListView, or DPanelList. DFrame does not have an “AddItem” function.

If the head is cut off, you need to reposition your camera.

Okay, so I took out the AddItem and it stopped showing up? thats odd, haha.

Any suggestions then how to make the frame the parent of the model?

Oh and now… when I remove the Frame it just revolves in mid air (the model panel)

You can give the vgui.Create function a second argument, which is the parent. So just do


local ModelView = vgui.Create("DModelPanel",CharCreate)

Okay this fixed it, Thanks

:smiley: