DModelPanel/SetAnimSpeed

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

Contents

DescriptionPanelFunc

Sets the speed used by DModelPanel:RunAnimation to advance frame on an entity sequence.

NOTE

Entity:FrameAdvance doesn't seem to have any functioning arguments and therefore changing this will not have any affect on the panel entity's sequence speed without reimplementation. It only affects the value returned by DModelPanel:GetAnimSpeed

Arguments

number animSpeed

The animation speed.

Examples

Example

A reimplementation of DModelPanel:LayoutEntity which will modify the entity's sequence playback rate based on the set animation speed. This example has Alyx run twice as fast as normal.

local mdl = vgui.Create("DModelPanel")
mdl:SetPos(20, 20)
mdl:SetSize(200, 200)
mdl:SetModel("models/alyx.mdl")

-- Play sequence twice as fast
mdl:SetAnimSpeed(2)
	
-- Make Alyx run
mdl:GetEntity():SetSequence(mdl:GetEntity():LookupSequence("run_all"))

-- Play animation
function mdl:LayoutEntity(ent)

	-- Playback rate based on anim speed
	ent:SetPlaybackRate(self:GetAnimSpeed())
	
	-- Advance frame
	ent:FrameAdvance()

end


Personal tools
Navigation