Entity/GetSequenceMoveDist

From Garry's Mod
Jump to: navigation, search
 Entity:GetSequenceMoveDist( )

Contents

Description

Returns an entity's sequence move distance (the change in position over the course of the entire sequence).

Arguments

number sequenceId

The sequence index.

Returns

number

The move distance of the sequence.

Examples

Example

Experiment which demonstrates that dividing the sequence move distance by Entity:SequenceDuration results in a value extremely close to Entity:GetSequenceGroundSpeed.

local ply, seq, move_dist, seq_dur, ground_speed = nil, nil, nil, nil, nil

function GM:Think()

	-- Player 1
	ply = Entity(1)
	
	-- Current sequence
	seq = ply:GetSequence()
	
	-- The move distance
	move_dist = ply:GetSequenceMoveDist(seq)
	
	if(move_dist == 0) then return end	-- If it doesn't move, don't bother
	
	-- The sequence duration
	seq_dur = ply:SequenceDuration(seq)
	
	-- Actual sequence ground speed
	ground_speed = ply:GetSequenceGroundSpeed(seq)
	
	-- Compare the calculated value to the actual value
	print(tostring(ground_speed-(move_dist/seq_dur)))

end

Output:

A sample of some of the calculated vs. actual value differences during a sprint forward followed by an abrupt stop.
-3.3345255872064e-006
3.3614563506035e-006
0
1.557984873557e-006
Personal tools
Navigation