From Valve Developer Community
Jump to: navigation, search

UTIL_BubbleTrail is a UTIL provided in the Source code for a trail of bubbles.


// Purpose: 
// Input  : Vector &from      | Where the bubble trail should emit from 
// Input  : Vector &to        | Where the bubble trail should go
// Input  : int - count       | How many bubbles
// Output : 
void UTIL_BubbleTrail( const Vector& from, const Vector& to, int count )


// Think every 0.1 seconds to make bubbles if we're flying through water.
void CHunterFlechette::BubbleThink()
//What this does is think every 0.1 seconds, and checks if the Flechette is in water.
//If it's not in the water, it exits the function and checks again in 0.1s.
//If it is in the water, then it creates a bubble trail every 0.1s.
        //SetNextThink having two params has something to do with SetContextThink. 
	SetNextThink( gpGlobals->curtime + 0.1f, s_szHunterFlechetteBubbles );
        //If it's not in the water, just check again in 0.1s.
	if ( GetWaterLevel()  == 0 )
        //Create a bubble trail, starting at the Origin-Velocity, so
        //the origin - 0.1 it's velocity, or behind the Flechette
        //The bubbles will head towards it's actual origin, like they were pulled
        //forward by it's movement through the water.
	UTIL_BubbleTrail( GetAbsOrigin() - GetAbsVelocity() * 0.1f, GetAbsOrigin(), 5 );