Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to make smooth trail? #214565
07/05/08 12:32
07/05/08 12:32
Joined: Jun 2008
Posts: 91
C
Coisox Offline OP
Junior Member
Coisox  Offline OP
Junior Member
C

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
C
Coisox Offline OP
Junior Member
Coisox  Offline OP
Junior Member
C

Joined: Jun 2008
Posts: 91
I found the solution. Not accurate but so so.

Code:
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);
	}
}



Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1