Hey list, also posted this on the steam forum In my HL2MP Ep1 mod I'm maually creating particles using a derived class from the original hl2 explosion, the explosion I'm currently working on only has a particle effect based on the fire_embers released after an explosion.
Everything's good about it except the moving speed I've tried a bunch of thing but can't seem to decrease the speed at which they float away from the explosion, normally this wouldn't be so important due to the short life span of the particles, but mine have a much higher lifetime (or dietime if you wanna kill it that) Here's the code I'm using: if ( m_fFlags & TE_EXPLFLAG_NOFIREBALL ) return; Vector offset; //Spread constricts as force rises float force = m_flForce; //Cap our force if ( force < EXPLOSION_FORCE_MIN ) force = 0.5f; if ( force > EXPLOSION_FORCE_MAX ) force = 0.5f; float spread = 1.0f - ( 0.15f * force ); SimpleParticle *pParticle; CSmartPtr<CExplosionParticle> pSimple = CExplosionParticle::Create( "exp_smoke" ); pSimple->SetSortOrigin( m_vecOrigin ); pSimple->SetNearClip( 64, 128 ); pSimple->GetBinding().SetBBox( m_vecOrigin - Vector( 128, 128, 128 ), m_vecOrigin + Vector( 128, 128, 128 ) ); //FIXME: Better sampling area offset = m_vecOrigin + ( m_vecDirection * 10.0f ); //Find area ambient light color and use it to tint smoke Vector worldLight = WorldGetLightForPoint( offset, true ); Vector tint; float luminosity; if ( worldLight == vec3_origin ) { tint = vec3_origin; luminosity = 0.0f; } else UTIL_GetNormalizedColorTintAndLuminosity( worldLight, &tint, &luminosity ); // We only take a portion of the tint tint = (tint * 0.25f)+(Vector(0.75f,0.75f,0.75f)); // // Embers // if ( m_Material_Embers[0] == NULL ) m_Material_Embers[0] = pSimple->GetPMaterial( "effects/holyn_particle1" ); if ( m_Material_Embers[1] == NULL ) m_Material_Embers[1] = pSimple->GetPMaterial( "effects/holyn_particle2" ); for ( int i = 0; i < 50; i++ ) { offset.Random( -3.0f, 3.0f ); offset += m_vecOrigin; pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), m_Material_Embers[random->RandomInt(0,1)], offset ); if ( pParticle != NULL ) { pParticle->m_flLifetime = 0.0f; pParticle->m_flDieTime = random->RandomFloat( 17.5f, 20.0f ); pParticle->m_vecVelocity.Random( -spread*4, spread*4 ); pParticle->m_vecVelocity += m_vecDirection / 6; VectorNormalize( pParticle->m_vecVelocity ); float fForce = 1.0f; //Scale the force down as we fall away from our main direction float vDev = ScaleForceByDeviation( pParticle->m_vecVelocity, m_vecDirection, spread ); pParticle->m_vecVelocity *= fForce * ( 0.75f * (vDev*vDev*0.15f) / 6 ); #if __EXPLOSION_DEBUG debugoverlay->AddLineOverlay( m_vecOrigin, m_vecOrigin + pParticle->m_vecVelocity, 255, 0, 0, false, 3 ); #endif pParticle->m_uchColor[0] = 255; pParticle->m_uchColor[1] = 255; pParticle->m_uchColor[2] = 255; pParticle->m_uchStartSize = random->RandomInt( 2, 3 ); //pParticle->m_uchStartSize = clamp( pParticle->m_uchStartSize, 4, 32 ); pParticle->m_uchEndSize = 1; pParticle->m_uchStartAlpha = 80; pParticle->m_uchEndAlpha = 0; pParticle->m_flRoll = random->RandomInt( 0, 360 ); pParticle->m_flRollDelta = random->RandomFloat( -3.0f, 3.0f ); } } And also a picture of how it currently looks like: http://i65.photobucket.com/albums/h208/InfernoNL/fo_complex0000-1.jpg I kinda wanna decrease the speed that much that by the time the particles have moved that far they would have almost faded already. I've messed with force, spread, velocity and more, the speed seems to remain unaltered. _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders