I'm trying to create trail effect for my Ball. Placing a new particle per frame each time my ball move makes the gap between trails particle too far due to very fast c_move.

So my idea is, each time c_move is called, get the lastPos and currentPos of the ball, and placing several particle between the gap.

But my code not working perfectly. Please advise. Or maybe if you have a workable function, please let me know.


function BeamAnimate()
{
vec_set(BallLastPos, BallCurrentPos);
vec_set(BallCurrentPos, Ball.x);

VECTOR beamDiff;
vec_diff(beamDiff,BallCurrentPos,BallLastPos);

var temp0;
var beamNum = integer ( vec_dist(BallLastPos,BallCurrentPos) / 0.1 );
for (temp0=0; temp0<beamNum; temp0++)
{
VECTOR beamIncrement;
vec_set (beamIncrement,beamDiff);
vec_scale(beamIncrement,0.1*temp0);
vec_add (BallLastPos,beamIncrement);
effect(ParticleEffectBeam,1,BallLastPos,nullvector);
}
}



function BallMove()
{
while (1)
{
c_move(Ball, vector(100*time_step,0,0), nullvector, GLIDE | IGNORE_PASSABLE);
BeamAnimate();
wait(1);
}
}



One more thing, is there any online tools that can convert my coding into proper UBBCode so that my coding is properly align?