|
4 registered members (PeWi, vince, Quad, 1 invisible),
4,489
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
How to make smooth trail?
#214565
07/05/08 12:32
07/05/08 12:32
|
Joined: Jun 2008
Posts: 91
Coisox
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2008
Posts: 91
|
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?
|
|
|
Re: How to make smooth trail?
[Re: Coisox]
#214695
07/06/08 14:40
07/06/08 14:40
|
Joined: Jun 2008
Posts: 91
Coisox
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2008
Posts: 91
|
I found the solution. Not accurate but so so.
function BeamAnimate()
{
vec_set(BallLastPos, BallCurrentPos);
vec_set(BallCurrentPos, Ball.x);
VECTOR BallHeading;
vec_diff(BallHeading,BallCurrentPos,BallLastPos);
vec_scale(BallHeading,0.1);
var temp0;
for (temp0=0; temp0<10; temp0++)
{
vec_add(BallLastPos,BallHeading);
effect(ParticleEffectBeam,1,BallLastPos,nullvector);
}
}
function BallMove()
{
while (1)
{
c_move(Ball, vector(100*time_step,0,0), nullvector, GLIDE);
BeamAnimate();
wait(1);
}
}
|
|
|
|