Garry's Mod Wiki

DModelPanel:SetLookAt

  DModelPanel:SetLookAt( Vector pos )

Description

Makes the panel's camera face the given position. Basically sets the camera's angles (DModelPanel:SetLookAng) after doing some math.

Arguments

1 Vector pos
The position to orient the camera toward.

Example

Creates a model panel focused on Colonel Odessa Cubbage's face.

BGPanel = vgui.Create("DPanel") BGPanel:SetPos(20, 20) BGPanel:SetSize(200, 200) local mdl = vgui.Create("DModelPanel", BGPanel) mdl:SetSize(BGPanel:GetSize()) mdl:SetModel("models/player/odessa.mdl") function mdl:LayoutEntity( Entity ) return end -- Disable cam rotation local headpos = mdl.Entity:GetBonePosition(mdl.Entity:LookupBone("ValveBiped.Bip01_Head1")) mdl:SetLookAt(headpos) mdl:SetCamPos(headpos-Vector(-15, 0, 0)) -- Move cam in front of face --mdl.Entity:SetEyeTarget(headpos-Vector(-15, 0, 0)) -- Makes Odessa look at the camera -- Commented out because the result is funnier without this
Output: