DModelPanel/SetLookAt

From Garry's Mod
Jump to: navigation, search
 DModelPanel:SetLookAt( )

Contents

DescriptionPanelFunc

Makes the panel's camera face the given position.

Arguments

Vector pos

The position to orient the camera toward.

Examples

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:



DModelPanel SetLookAt example1.jpg
Personal tools
Navigation