Difference between revisions of "UTIL ApproachAngle"

From Valve Developer Community
Jump to: navigation, search
m (title)
m (link)
Line 1: Line 1:
 
{{wrongtitle|UTIL_ApproachAngle}}
 
{{wrongtitle|UTIL_ApproachAngle}}
UTIL_ApproachAngle is a UTIL provided in the Source code for 'approaching' a target value, as an angle. It is useful for creating non-linear movement when turning.
+
UTIL_ApproachAngle is a [[UTIL]] provided in the Source code for 'approaching' a target value, as an angle. It is useful for creating non-linear movement when turning.
  
 
{{Todo|Verify this!}}
 
{{Todo|Verify this!}}

Revision as of 23:30, 12 April 2011

Template:Wrongtitle UTIL_ApproachAngle is a UTIL provided in the Source code for 'approaching' a target value, as an angle. It is useful for creating non-linear movement when turning.

To do: Verify this!

Usage

//-----------------------------------------------------------------------------
// Purpose: 
//          
// Input  : target - Target value to reach
// Input  : value - Current value
// Input  : speed - Speed at which to approach the target value
// Output : float - Current value? //TODO: Check
//-----------------------------------------------------------------------------
inline float UTIL_ApproachAngle( float target, float value, float speed )
{
	return ApproachAngle( target, value, speed );
}


Examples

//Called every frame in a Think function, approaches the new angle at a rate of MAX_WIND_CHANGE (5.0f)
m_nDirCurrent = UTIL_ApproachAngle( m_nDirTarget, m_nDirCurrent, MAX_WIND_CHANGE );
m_goalHeadCorrection.x = UTIL_Approach( m_goalHeadCorrection.x * s0 + vTargetAngles.x * s1, m_goalHeadCorrection.x, 10.0 );