Author Topic: How do I center a bullet trail particle or make it stay on the bullet?  (Read 1070 times)

So I'm working on a weaponset, and I want the bullets to use a nifty particle tracer rather than a model (with a few exceptions that I'll get around to some other time). The problem is that the particle tracer isn't centered properly atop the bullet.
Sorry about the pagestretch but it's not really very visible otherwise.

That dot in the crook between the big star and the red bricks on the bottom right seems to be the actual bullet (or maybe that's just another particle and i forgeted up again)
Here's the relevant script:
Code: [Select]
datablock ParticleData(vnormalTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 120;
lifetimeVarianceMS = 0;
//spinSpeed = 10.0;
//spinRandomMin = -50.0;
//spinRandomMax = 50.0;
spinSpeed = 0.0;
spinRandomMin = 0.0;
spinRandomMax = 0.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;

textureName = "add-ons/Weapon_Vectorman/NormalShot";
//animTexName = "~/data/particles/dot";

// Interpolation variables
colors[0] = "1 1 1 1";
colors[1] = "1 1 1 1";
colors[2] = "1 1 1 1";
sizes[0] = 3.0;
sizes[1] = 3.0;
sizes[2] = 0.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
//So as it turns out, trail particles tend to hang out in one corner of their respective projectiles. I'm not thrilled.
datablock ParticleEmitterData(vnormalTrailEmitter)
{
   ejectionPeriodMS = 1; //was 2, i changed this
   periodVarianceMS = 0;

   ejectionVelocity = 0; //0.25;
   velocityVariance = 0; //0.10;

   ejectionOffset = 0;

   thetaMin         = 0.0;
   thetaMax         = 0.0;  //was 90.0?

   particles = vnormalTrailParticle;

   useEmitterColors = true;
};

AddDamageType("vnormal",   '<bitmap:add-ons/Weapon_Vectorman/CI_normal> %1',    '%2 <bitmap:add-ons/Weapon_Vectorman/CI_normal> %1',0.2,1);
datablock ProjectileData(vnormalProjectile)
{
   projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
   directDamage        = 30;
   directDamageType    = $DamageType::vnormal;
   radiusDamageType    = $DamageType::vnormal;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 10;
   brickExplosionMaxVolume = 1;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloating = 2;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse     = 400;
   verticalImpulse  = 400;
   explosion           = vnormalExplosion;
   particleEmitter     = vnormalTrailEmitter; //bulletTrailEmitter;

   muzzleVelocity      = 150;
   velInheritFactor    = 1;

   armingDelay         = 00;
   lifetime            = 4000;
   fadeDelay           = 3500;
   bounceElasticity    = 0.5;
   bounceFriction      = 0.20;
   isBallistic         = false;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   uiName = "Vectorman Shot";
};
What am I doing wrong here? Is there an easier way to just stick a particle directly on a projectile? Is there something I'm missing here? How do I center a bullet trail particle, or better yet, how do I make a particle stay on a bullet?
« Last Edit: March 13, 2015, 11:11:12 AM by King of the Bill »

Is your particle texture's resolution a multiple of 2? Pecon and I had that problem with one once and it was fixed by resizing the image.

If the problem isn't what Jetz is saying, are you sure the particle is coming out of the muzzle point, and moving in the correct direction? Assign the model to the gun bullet and remove the particle to test it.

Resolution is 160x160, would that cause anything?
(note that in the attached screenshot, the particle was scaled to 5 instead of to 3)
If the problem isn't what Jetz is saying, are you sure the particle is coming out of the muzzle point, and moving in the correct direction? Assign the model to the gun bullet and remove the particle to test it.
There is no muzzlepoint for the weapon, it's using blank.dts. I was sorta worried this would be an issue but I can't figure out modeling software. ideally, the hand would be held a little more diagonally and have a firing animation that appears to be pumping backward slightly.
Also the model for the projectile is already the gun bullet, so that might be the issue too. I was looking at what other models to use but I left it as bullet for now.

Resolution is 160x160, would that cause anything?

Yes. Render it as/resize it to 128x128 or 256x256.
I figure the engine is extending the size to 256x256 and thus causing the image to shift up to the top left of that frame.

+---------+---+
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|     160x|   |
|---------+   |
|             |
|             |
|             |
|         256x|
+-------------+
« Last Edit: March 12, 2015, 03:21:18 PM by portify »

Yes. Render it as/resize it to 128x128 or 256x256.
I figure the engine is extending the size to 256x256 and thus causing the image to shift up to the top left of that frame.

+---------+---+
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|         |   |
|     160x|   |
|---------+   |
|             |
|             |
|             |
|         256x|
+-------------+

Ahhh! That explains it. Thanks, I'll see what I can do.
Edit: Worked, thanks a ton!
« Last Edit: March 12, 2015, 03:38:43 PM by King of the Bill »